R
redweek
Unregistered / Unconfirmed
GUEST, unregistred user!
我把数据库里的字段"UseName"(姓名),"BankCode"(银行帐号)等信息转换成Excel 文件输出时,"BankCode"(银行帐号)中的内容(19位的帐号),在excel文件中已科学计算法存在.并且,最后5位数字都变成了0,非常奇怪.请大虾解答!!很急.
procedure TForm_ClientInfo.BitB_ExcelClick(Sender: TObject);
var
i,row,j:integer;
ExcelApplication1: TExcelApplication;
ExcelWorkbook1: TExcelWorkbook;
ExcelWorksheet1: TExcelWorksheet;
BkString:AnsiString;
begin
if SaveDialog1.Execute then
begin
ExcelApplication1:=TExcelApplication.Create(self);
ExcelWorkbook1:=TExcelWorkbook.Create(self);
ExcelWorksheet1:=TExcelWorksheet.Create(self);
Screen.Cursor:=crHourGlass;
ExcelApplication1.Connect;
ExcelApplication1.Workbooks.Add(Null,0);
ExcelWorkBook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorkSheet1.ConnectTo(ExcelWorkBook1.Sheets[1] as _WorkSheet);
ExcelWOrkSheet1.Cells.Item[1,1]:='小区名称';
ExcelWOrkSheet1.Cells.Item[1,2]:='楼宇号';
ExcelWOrkSheet1.Cells.Item[1,3]:='楼宇名称';
ExcelWOrkSheet1.Cells.Item[1,4]:='单 元';
ExcelWOrkSheet1.Cells.Item[1,5]:='门牌号码';
ExcelWOrkSheet1.Cells.Item[1,6]:='用户编号';
ExcelWOrkSheet1.Cells.Item[1,7]:='业主姓名';
ExcelWOrkSheet1.Cells.Item[1,8]:='用户地址';
ExcelWOrkSheet1.Cells.Item[1,9]:='银行卡号';
ExcelWOrkSheet1.Cells.Item[1,10]:='联系方式';
ExcelWOrkSheet1.Cells.Item[1,11]:='备 注';
With MyDataModule do
begin
AQ_ClientInfo.First;
Row:=1; //...第一行.....
While not AQ_ClientInfo.Eof do
begin
Row:=Row+1; //..增加一行....
ExcelWOrkSheet1.Cells.Item[row,1]:=AQ_ClientInfo.fieldbyname('AreaName').AsString;
ExcelWOrkSheet1.Cells.Item[row,2]:=AQ_ClientInfo.fieldbyname('BuildNo').AsString;
ExcelWOrkSheet1.Cells.Item[row,3]:=AQ_ClientInfo.fieldbyname('BuildName').AsString;
ExcelWOrkSheet1.Cells.Item[row,4]:=AQ_ClientInfo.fieldbyname('UnitNo').AsString;
ExcelWOrkSheet1.Cells.Item[row,5]:=AQ_ClientInfo.fieldbyname('RoomNo').AsString;
ExcelWOrkSheet1.Cells.Item[row,6]:=AQ_ClientInfo.fieldbyname('ClientCode').AsString;
ExcelWOrkSheet1.Cells.Item[row,7]:=AQ_ClientInfo.fieldbyname('UseName').AsString;
ExcelWOrkSheet1.Cells.Item[row,8]:=AQ_ClientInfo.fieldbyname('Address').AsString;
ExcelWOrkSheet1.Cells.Item[row,9].ColumnWidth :=30;
ExcelWOrkSheet1.Cells.Item[row,9].WrapText := True; //...该列转换成文本...
BkString:=AQ_ClientInfo.fieldbyname('BankCode').AsString ;
ExcelWOrkSheet1.Cells.Item[row,9]:=Trim(BkString) ;
//..问题在这里,BkString='12345678998765432199' ,在Excel中成了1.234567E+19
//...在Excel中点击后展开123456789987600000
ExcelWOrkSheet1.Cells.Item[row,10]:=AQ_ClientInfo.fieldbyname('TelNumb').AsString;
AQ_ClientInfo.Next;
end;
end;
ExcelWorkBook1.SaveCopyAs(SaveDialog1.FileName+'.xls');
ExcelWOrkBook1.Close(false);
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
ExcelApplication1.Free; //清除EXcel
ExcelWOrkSheet1.Free;
ExcelWorkbook1.Free;
Screen.Cursor:=crDefault;
end;
end;
procedure TForm_ClientInfo.BitB_ExcelClick(Sender: TObject);
var
i,row,j:integer;
ExcelApplication1: TExcelApplication;
ExcelWorkbook1: TExcelWorkbook;
ExcelWorksheet1: TExcelWorksheet;
BkString:AnsiString;
begin
if SaveDialog1.Execute then
begin
ExcelApplication1:=TExcelApplication.Create(self);
ExcelWorkbook1:=TExcelWorkbook.Create(self);
ExcelWorksheet1:=TExcelWorksheet.Create(self);
Screen.Cursor:=crHourGlass;
ExcelApplication1.Connect;
ExcelApplication1.Workbooks.Add(Null,0);
ExcelWorkBook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorkSheet1.ConnectTo(ExcelWorkBook1.Sheets[1] as _WorkSheet);
ExcelWOrkSheet1.Cells.Item[1,1]:='小区名称';
ExcelWOrkSheet1.Cells.Item[1,2]:='楼宇号';
ExcelWOrkSheet1.Cells.Item[1,3]:='楼宇名称';
ExcelWOrkSheet1.Cells.Item[1,4]:='单 元';
ExcelWOrkSheet1.Cells.Item[1,5]:='门牌号码';
ExcelWOrkSheet1.Cells.Item[1,6]:='用户编号';
ExcelWOrkSheet1.Cells.Item[1,7]:='业主姓名';
ExcelWOrkSheet1.Cells.Item[1,8]:='用户地址';
ExcelWOrkSheet1.Cells.Item[1,9]:='银行卡号';
ExcelWOrkSheet1.Cells.Item[1,10]:='联系方式';
ExcelWOrkSheet1.Cells.Item[1,11]:='备 注';
With MyDataModule do
begin
AQ_ClientInfo.First;
Row:=1; //...第一行.....
While not AQ_ClientInfo.Eof do
begin
Row:=Row+1; //..增加一行....
ExcelWOrkSheet1.Cells.Item[row,1]:=AQ_ClientInfo.fieldbyname('AreaName').AsString;
ExcelWOrkSheet1.Cells.Item[row,2]:=AQ_ClientInfo.fieldbyname('BuildNo').AsString;
ExcelWOrkSheet1.Cells.Item[row,3]:=AQ_ClientInfo.fieldbyname('BuildName').AsString;
ExcelWOrkSheet1.Cells.Item[row,4]:=AQ_ClientInfo.fieldbyname('UnitNo').AsString;
ExcelWOrkSheet1.Cells.Item[row,5]:=AQ_ClientInfo.fieldbyname('RoomNo').AsString;
ExcelWOrkSheet1.Cells.Item[row,6]:=AQ_ClientInfo.fieldbyname('ClientCode').AsString;
ExcelWOrkSheet1.Cells.Item[row,7]:=AQ_ClientInfo.fieldbyname('UseName').AsString;
ExcelWOrkSheet1.Cells.Item[row,8]:=AQ_ClientInfo.fieldbyname('Address').AsString;
ExcelWOrkSheet1.Cells.Item[row,9].ColumnWidth :=30;
ExcelWOrkSheet1.Cells.Item[row,9].WrapText := True; //...该列转换成文本...
BkString:=AQ_ClientInfo.fieldbyname('BankCode').AsString ;
ExcelWOrkSheet1.Cells.Item[row,9]:=Trim(BkString) ;
//..问题在这里,BkString='12345678998765432199' ,在Excel中成了1.234567E+19
//...在Excel中点击后展开123456789987600000
ExcelWOrkSheet1.Cells.Item[row,10]:=AQ_ClientInfo.fieldbyname('TelNumb').AsString;
AQ_ClientInfo.Next;
end;
end;
ExcelWorkBook1.SaveCopyAs(SaveDialog1.FileName+'.xls');
ExcelWOrkBook1.Close(false);
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
ExcelApplication1.Free; //清除EXcel
ExcelWOrkSheet1.Free;
ExcelWorkbook1.Free;
Screen.Cursor:=crDefault;
end;
end;