文件名称:delphi excelApplication示例
文件大小:381KB
文件格式:RAR
更新时间:2015-01-19 08:54:40
delphi excelApplication
procedure TForm1.btn7Click(Sender: TObject); var i,row,column:integer; begin Try ExcelApplication1.Connect; Except MessageDlg('Excel may not be installed',mtError, [mbOk], 0); Abort; End; ExcelApplication1.Visible[0]:=True; ExcelApplication1.Caption:='Excel Application'; ExcelApplication1.Workbooks.Add(Null,0); ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]); ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet); Tabel1.Open; row:=1; While Not(Tabel1.Eof) do begin column:=1; for i:=1 to Tabel1.FieldCount do begin ExcelWorksheet1.Cells.Item[row,column]:=Tabel1.Fields[i-1].AsString; column:=column+1; end; Tabel1.Next; inc(row); end; End;
【文件预览】:
excel操作
----Unit1.ddp(51B)
----Project1.res(876B)
----Unit1.dcu(14KB)
----Unit1.~ddp(51B)
----db1.mdb(136KB)
----Unit1.dfm(5KB)
----Project1.~dpr(188B)
----Project1.cfg(590B)
----Project1.dpr(188B)
----Unit1.~dfm(5KB)
----Project1.exe(936KB)
----Project1.dof(2KB)
----Unit1.~pas(5KB)
----Unit1.pas(5KB)