L
lljimo
Unregistered / Unconfirmed
GUEST, unregistred user!
银行账号一般都很长有23位的,导出到excel结果是 7.2042E+20 如何将其变成文本格式,我写的代码如下: 需要将第二列改成文本格式,第四列是数字格式 var ExcelApplication1:TExcelApplication; ExcelWorksheet1:TExcelWorksheet; ExcelWorkbook1:TExcelWorkbook; i,j:integer; begin try ExcelApplication1:=TExcelApplication.Create(Application); ExcelWorksheet1:=TExcelWorksheet.Create(Application); ExcelWorkbook1:=TExcelWorkbook.Create(Application); ExcelApplication1.Connect; ExcelApplication1.Visible[0]:=True; except Application.Messagebox('Excel没有安装!','Hello',MB_ICONERROR+mb_Ok); Abort; end; try ExcelApplication1.Workbooks.Add(EmptyParam,0); ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]); ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1]as _worksheet); DBGridEh1.DataSource.DataSet.First; for j:=0 to DBGridEh1.DataSource.DataSet.Fields.Count-1 do begin ExcelWorksheet1.Cells.item[1,j+1]:=DBGridEh1.Columns[j].Title.Caption;//导出DBGridEh1中显示的字段标题 //ExcelWorksheet1.Cells.item[3,j+1]:=DBGridEh1.DataSource.DataSet.Fields[j].DisplayLabel;//导出数据库中字段名 ExcelWorksheet1.Cells.item[1,j+1].font.size:='10'; end; for i:=2 to DBGridEh1.DataSource.DataSet.RecordCount + 1 do //从excel的第2行到最后 begin for j:= 0 to DBGridEh1.DataSource.DataSet.Fields.Count-1 do //从dbgrid4的第1列到最后 begin //ExcelWorksheet1.Cells.item[i,j+1]:=DBGridEh1.DataSource.DataSet.Fields[j].Asstring; //ExcelWorksheet1.Cells.item[i,j+1].font.size:='10'; ExcelWorksheet1.Cells.item[i,j+1]:=DBGridEh1.DataSource.DataSet.Fields[j].Asstring; ExcelWorksheet1.Cells.item[i,j+1].font.size:='10'; end; DBGridEh1.DataSource.DataSet.Next; end; ExcelWorksheet1.Columns.AutoFit; // ExcelWorksheet1.Cells.item[1,2]:='预测表'+Formatdatetime('YYYYmmdd',Now);//DBGridEh1.Columns[0].FieldName; //在excel中第一行显示标题,产品物料明晰表 ExcelWorksheet1.Cells.Item[1,2].font.size:='14'; finally ExcelWorkSheet1.Disconnect; ExcelWorkBook1.Disconnect; ExcelApplication1.Disconnect; end;应该如何修改