delphi 用别名的方式访问excel写入数据,实现非标格式报表输出

来源:互联网 发布:防止微信屏蔽分享域名 编辑:程序博客网 时间:2024/04/30 18:11
unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, excel2000, StdCtrls,  ComObj;type  TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;var  Form1: TForm1;  EApp,workbook:variant;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin EApp := CreateOleObject( 'Excel.Application' );     EApp.Workbooks.Open('d:\book4.xls');     EApp.Visible:=true;     EApp.worksheets[1].activate;     EApp.ActiveSheet.Range['re1'].Value :='test';        //--re1为excel单元格别名     EApp.quit;end;end.
0 0
原创粉丝点击