K
kimfeng
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button5Click(Sender: TObject);
var
_tmp_WorkBook: _WorkBook;
TemplateName: string;
ST: String;
begin
ExcelApplication1.Connect;
ExcelApplication1.Visible[0] := True;
ExcelApplication1.Caption := '应用程序调用 Microsoft Excel';
TemplateName:= ExtractFilePath(Application.ExeName) + 'Templates.xls';
_tmp_WorkBook:= ExcelApplication1.Workbooks.Open(TemplateName, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0);
ExcelWorkbook1.ConnectTo(_tmp_WorkBook);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _WorkSheet);
{我想要取WorkSheet的名称}
Label1.Caption:= ExcelWorkbook1.Names.Item(1, 1, 1).Value
//错误在这里:“不正确的变量类型”
//
end;
var
_tmp_WorkBook: _WorkBook;
TemplateName: string;
ST: String;
begin
ExcelApplication1.Connect;
ExcelApplication1.Visible[0] := True;
ExcelApplication1.Caption := '应用程序调用 Microsoft Excel';
TemplateName:= ExtractFilePath(Application.ExeName) + 'Templates.xls';
_tmp_WorkBook:= ExcelApplication1.Workbooks.Open(TemplateName, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0);
ExcelWorkbook1.ConnectTo(_tmp_WorkBook);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _WorkSheet);
{我想要取WorkSheet的名称}
Label1.Caption:= ExcelWorkbook1.Names.Item(1, 1, 1).Value
//错误在这里:“不正确的变量类型”
//
end;