d7调用excel出错not supported by automation object
d7调用excel时出错ethod 'ColumnsWidth' not supported by automation object
var ExcelApp: Variant;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := True;
ExcelApp.Caption := '应用程序调用 Microsoft Excel';
ExcelApp.WorkBooks.Add;
ExcelApp.WorkBooks.Open( 'C:\test1.xls' );
ExcelApp.ActiveSheet.Columns[1].ColumnsWidth := 115;
运行时报错如下:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOleError with message 'Method 'ColumnsWidth' not supported by automation object'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
d7调用excel时出错ethod 'ColumnsWidth' not supported by automation object
var ExcelApp: Variant;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := True;
ExcelApp.Caption := '应用程序调用 Microsoft Excel';
ExcelApp.WorkBooks.Add;
ExcelApp.WorkBooks.Open( 'C:\test1.xls' );
ExcelApp.ActiveSheet.Columns[1].ColumnsWidth := 115;
运行时报错如下:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOleError with message 'Method 'ColumnsWidth' not supported by automation object'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
uses里加入, OleServer, Excel97(或excelxp等)没有?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,DB, ComCtrls, Grids, DBGrids, Spin, StdCtrls, Buttons, ExtCtrls,
ActnList, XPMan, Mask, DBCtrls, DBNavPlus, FileCtrl,SHELLAPI,
ComObj,INIFILES, ADODB, OleServer, Excel2000;
希望高手来看一下。