请问如果给EXCEL增加一个SHEET?急!!!
excelobj.OlePropertyGet( "Workbooks ").OleFunction( "Add ", 1)不行啊
[解决办法]
void __fastcall TForm1::Button1Click(TObject *Sender)
{
WideString theXls;
theXls=ExtractFilePath(Application-> ExeName) + "book.xls ";
TCOM_Application iExcelApp; //#include "Excel_2K_SRVR.h "
iExcelApp=CoExcelApplication::Create();
iExcelApp-> set_Visible(0,true);
Workbooks *ibooksPtr;
iExcelApp-> get_Workbooks(&ibooksPtr);
ibooksPtr-> Close(0);
ibooksPtr-> Open(theXls.c_bstr(),
TNoParam(),TNoParam(),TNoParam(),TNoParam(),
TNoParam(),TNoParam(),TNoParam(),TNoParam(),
TNoParam(),TNoParam(),TNoParam(),TNoParam(),
0);
_Workbook * ibookPtr;
ibookPtr=iExcelApp-> get_ActiveWorkbook();
Sheets* isheetsPtr;
isheetsPtr=ibookPtr-> get_Worksheets();
IDispatch* x;
isheetsPtr-> Add(TNoParam(),TNoParam(),TVariant(3),TNoParam(),0,&x);//3是加3张表,1是1张
ShowMessage( "关闭 ");
isheetsPtr-> Release();
ibookPtr-> Release();
ibooksPtr-> Release();
iExcelApp-> Quit();
}