unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Excel2000, OleServer, StdCtrls, Grids, DBGrids, DB, DBTables;type
TForm1 = class(TForm)
DataSource1: TDataSource;
Query1: TQuery;
DBGrid1: TDBGrid;
Button1: TButton;
ExcelApplication1: TExcelApplication;
ExcelWorkbook1: TExcelWorkbook;
ExcelWorksheet1: TExcelWorksheet;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
beginend;end.begin 与 and 之间的代码如何编写,最好不要用procedure,直接编程
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Excel2000, OleServer, StdCtrls, Grids, DBGrids, DB, DBTables;type
TForm1 = class(TForm)
DataSource1: TDataSource;
Query1: TQuery;
DBGrid1: TDBGrid;
Button1: TButton;
ExcelApplication1: TExcelApplication;
ExcelWorkbook1: TExcelWorkbook;
ExcelWorksheet1: TExcelWorksheet;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
beginend;end.begin 与 and 之间的代码如何编写,最好不要用procedure,直接编程
解决方案 »
- Property 是衔接桥梁,同时也
- StringGrid的内容和数据集比较结果在DBGridEh中显示出来.
- 我客戶端是ado2.8,服務器上是SQL2000,ado2.7,是否對客戶端有什麼影響?
- 请教学Delphi的朋友
- 菜鸟提问:我new application 后,想把类名TForm1换成别的,为什么都不行呢?
- 请问哪儿有类似画图板和写字板的原代码?
- 请教几个fastreport的问题,主要是主从表的
- printer出问题,在线等待!!!
- 新手提滴一个不知道是不是技术上滴问题!!!
- 写这个句子为什么不行呢
- 请教一个表较麻烦的界面的问题 !
- 请问:只知道一个窗体类的类名的字符形式,能不能创建这个窗体?
msExcel,MsExcelWorkBook, MsExcelWorkSheet:Variant;
i : integer;
begin
try
i:=1;
MsExcel := CreateOleObject('Excel.Application'); //Create
MsExcelWorkBook:=msExcel.WorkBooks.Add; //Add Workbooks
MsExcelWorkSheet:=msExcel.Worksheets['sheet1']; //Choose Sheet
MsExcelWorkSheet.Name := 'Diary'; //Excel sheet name
MsExcel.caption:='My Diary'; //Excel Caption
MsExcel.Visible := True; //Show
with Adoquery1 do
begin
First;
while not eof do //From DataBase To Excel
begin
MsExcelWorkSheet.Range['A'+Inttostr(i+1)].Value := FieldByName('D_Date').AsString;
MsExcelWorkSheet.Range['B'+Inttostr(i+1)].Value := FieldByName('Week').AsString;
MsExcelWorkSheet.Range['C'+Inttostr(i+1)].Value := FieldByName('Weather').AsString;
MsExcelWorkSheet.Range['D'+Inttostr(i+1)].Value := FieldByName('Content').AsString;
inc(i);
next;
end;
end;
MsExcelWorkSheet.Range['A1'].Font.Size := 24;
MsExcelWorkSheet.Range['A1'].Value := 'My Diary';
MsExcelWorkSheet.Cells.EntireColumn.AutoFit;
finally
MsExcel.Quit;
end;