C
chengwind
Unregistered / Unconfirmed
GUEST, unregistred user!
我在控制各列的宽度时出现错误如下:
Method 'ColumnsWidth' not supported by automation object.
我的代码:(请问如何控制列宽)
procedure Tfrm_bExcel.Button1Click(Sender: TObject);
var
ExcelApp,WorkBook:Variant; //声明为OLE Automation 对象
begin
inherited;
try
ExcelApp:=CreateOleObject('Excel.Application');
WorkBook:=CreateOleobject('Excel.Sheet');
//创建OLE对象Excel Application与 WorkBook
except
ShowMessage('您的机器里未安装Microsoft Excel。');
Exit;
end;
ExcelApp.Caption := '应用程序调用 Microsoft Excel';
ExcelApp.WorkBooks.Add;
ExcelApp.WorkSheets[1].Activate;
ExcelApp.Cells[1,4].Value := '第一行第四列';
ExcelApp.ActiveSheet.Columns[1].ColumnsWidth := 15; // 报错
ExcelApp.Visible := True;
end;
Method 'ColumnsWidth' not supported by automation object.
我的代码:(请问如何控制列宽)
procedure Tfrm_bExcel.Button1Click(Sender: TObject);
var
ExcelApp,WorkBook:Variant; //声明为OLE Automation 对象
begin
inherited;
try
ExcelApp:=CreateOleObject('Excel.Application');
WorkBook:=CreateOleobject('Excel.Sheet');
//创建OLE对象Excel Application与 WorkBook
except
ShowMessage('您的机器里未安装Microsoft Excel。');
Exit;
end;
ExcelApp.Caption := '应用程序调用 Microsoft Excel';
ExcelApp.WorkBooks.Add;
ExcelApp.WorkSheets[1].Activate;
ExcelApp.Cells[1,4].Value := '第一行第四列';
ExcelApp.ActiveSheet.Columns[1].ColumnsWidth := 15; // 报错
ExcelApp.Visible := True;
end;