_ Application excelapp;
_ Application excelprotectapp;
Workbooks workbooks;
_ Workbook;
Worksheets worksheets;
_ Worksheet;
// File opening options
Colevariant voptional (long) disp_e_paramnotfound, vt_error );
// COM Initialization
If (! Afxoleinit ())
{
Afxmessagebox (msg_library_ini_failed );
Return false;
}
// Excel
// Excel
If (! Excelapp. createdispatch ("Excel. application "))
{
Afxmessagebox (msg_excel_create_failed );
Return false;
}
If (! Excelprotectapp. createdispatch ("Excel. application "))
{
Afxmessagebox (msg_excel_create_failed );
Return false;
}
# Ifdef _ debug
Excelapp. setvisible (true );
Excelapp. setusercontrol (true );
# Endif
Workbooks = excelapp. getworkbooks ();
// Create a new workbook
Workbook = workbooks. Add (voptional );
Worksheets = Workbook. getworksheets ();
While (worksheets. getcount ()! = 1)
{
Worksheet = worksheets. getitem (colevariant (short) 1 ));
// Delete Worksheet
Worksheet. Delete ();
}
// Save the work
Workbook. saveas (colevariant) (strvalue + cstrfilename ),
Covoptional,
Covoptional, covoptional, c_accessmode, covoptional, covoptional,
Covoptional, covoptional, covoptional );