9
954ken
Unregistered / Unconfirmed
GUEST, unregistred user!
如下代码:
procedure TForm1.Button1Click(Sender: TObject);
var temp_worksheet:_WorkSheet;
begin
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=True;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(EmptyParam,0));
ExcelWorkbook1.Title[0]:='Excel Test';
Temp_Worksheet:=ExcelWorkbook1.WorkSheets.Add(EmptyParam,EmptyParam,1,xlworksheet,0) as _WorkSheet;
ExcelWorkSheet1.ConnectTo(temp_worksheet);
ExcelWorkSheet1.Cells[1,1].value:='TEST';
ExcelWorkSheet1.Cells[1,1].font.size:=5;
end;
编译时提示
ExcelWorkSheet1.Cells[1,1].value:='TEST';
这一行有如下错误信息:
[Error] Unit1.pas(41): Class does not have a default property
我查了excel的帮助,vb里写作Cells(1,1).values
但是用在delphi中还是错。
如果用那种CreateOleObject的方法来操作excel则可以写成Cells[1,1].value:='TEST';
那么使用TExcelWorkSheet应如何写呢?
请各位不吝赐教。50分!
procedure TForm1.Button1Click(Sender: TObject);
var temp_worksheet:_WorkSheet;
begin
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=True;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(EmptyParam,0));
ExcelWorkbook1.Title[0]:='Excel Test';
Temp_Worksheet:=ExcelWorkbook1.WorkSheets.Add(EmptyParam,EmptyParam,1,xlworksheet,0) as _WorkSheet;
ExcelWorkSheet1.ConnectTo(temp_worksheet);
ExcelWorkSheet1.Cells[1,1].value:='TEST';
ExcelWorkSheet1.Cells[1,1].font.size:=5;
end;
编译时提示
ExcelWorkSheet1.Cells[1,1].value:='TEST';
这一行有如下错误信息:
[Error] Unit1.pas(41): Class does not have a default property
我查了excel的帮助,vb里写作Cells(1,1).values
但是用在delphi中还是错。
如果用那种CreateOleObject的方法来操作excel则可以写成Cells[1,1].value:='TEST';
那么使用TExcelWorkSheet应如何写呢?
请各位不吝赐教。50分!