谢谢各位的回复! 目前我又遇到一个问题,请看我的源代码: ...... procedure TForm1.BtnCreateTableClick(Sender: TObject); var sheet:variant; i,j:Integer; Template:OleVariant; begin ExcelApplication1.Connect; ExcelApplication1.Visible[0]:=true; Template:=Emptyparam; ExcelApplication1.Workbooks.Add(Template,0); sheet:=ExcelApplication1.Workbooks[1].Worksheets[1]; sheet.Name:='调度日报表'; with Table1 do begin First; j:=1; While Not EOF do begin for i:=0 to Fieldcount-1 do sheet.cells[j,i+1]:=Fields[i].AsString; j:=j+1; Next; end; end; ...... 这段代码实现
谢谢各位的回复! 目前我又遇到一个问题,请看我的源代码: ...... procedure TForm1.BtnCreateTableClick(Sender: TObject); var sheet:variant; i,j:Integer; Template:OleVariant; begin ExcelApplication1.Connect; ExcelApplication1.Visible[0]:=true; Template:=Emptyparam; ExcelApplication1.Workbooks.Add(Template,0); sheet:=ExcelApplication1.Workbooks[1].Worksheets[1]; sheet.Name:='调度日报表'; with Table1 do begin First; j:=1; While Not EOF do begin for i:=0 to Fieldcount-1 do sheet.cells[j,i+1]:=Fields[i].AsString; j:=j+1; Next; end; end; ...... 这段代码实现DELPHI向Excel非模板worksheet中写入字段值 Template:=Emptyparam; ExcelApplication1.Workbooks.Add(Template,0); 而现在我要向已经做好的(设置好打印格式的)Excel模板中写入数据,请问该如何做,Add()的参数如何选。
我的实现方法是这样的:用Formula one6.1控件,它能打开excel97的文件。
先用excel做一个模板,当然打印格式也做好了.
再用程序控制写入数据并打印。
http://go.163.com/~ssudi
那里有解决方案,还有源码呢!美观漂亮方便呀!
目前我又遇到一个问题,请看我的源代码:
......
procedure TForm1.BtnCreateTableClick(Sender: TObject);
var
sheet:variant;
i,j:Integer;
Template:OleVariant;
begin
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=true;
Template:=Emptyparam;
ExcelApplication1.Workbooks.Add(Template,0);
sheet:=ExcelApplication1.Workbooks[1].Worksheets[1];
sheet.Name:='调度日报表';
with Table1 do
begin
First;
j:=1;
While Not EOF do
begin
for i:=0 to Fieldcount-1 do
sheet.cells[j,i+1]:=Fields[i].AsString;
j:=j+1;
Next;
end;
end;
......
这段代码实现
目前我又遇到一个问题,请看我的源代码:
......
procedure TForm1.BtnCreateTableClick(Sender: TObject);
var
sheet:variant;
i,j:Integer;
Template:OleVariant;
begin
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=true;
Template:=Emptyparam;
ExcelApplication1.Workbooks.Add(Template,0);
sheet:=ExcelApplication1.Workbooks[1].Worksheets[1];
sheet.Name:='调度日报表';
with Table1 do
begin
First;
j:=1;
While Not EOF do
begin
for i:=0 to Fieldcount-1 do
sheet.cells[j,i+1]:=Fields[i].AsString;
j:=j+1;
Next;
end;
end;
......
这段代码实现DELPHI向Excel非模板worksheet中写入字段值
Template:=Emptyparam;
ExcelApplication1.Workbooks.Add(Template,0);
而现在我要向已经做好的(设置好打印格式的)Excel模板中写入数据,请问该如何做,Add()的参数如何选。