CApplication app;
CWorkbook book;
CWorkbooks books;
CWorksheet sheet;
CWorksheets sheets;
CRange range;
CRange cols.
LPDISPATCH lpDisp;
if(! App. CreateDispatch (_T (" Excel. Application ")))
{
AfxMessageBox (_T (" Error! Creat Excel Application Server Faile!" ));
return;//exit (1);
}
/* judge current Excel version */
Cstrings strExcelVersion=app. Get_Version (); \ \ executive members find
Int iStart=0;
StrExcelVersion=strExcelVersion. Tokenize (_T (". "), iStart);
If (_T (" 11 ")==strExcelVersion)
{
MessageBox (_T (" the current version is Excel 2003 "));
}
Else if (_T (" 12 ")==strExcelVersion)
{
MessageBox (_T (" the current version is Excel 2007 "));
}
The else
{
MessageBox (_T (" the current version is Excel other version "));
}