How to add excel worksheet ?

A

Alexei

Hi,

Using VC 7.0 with excel 2000

COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
CApplication app;
app.CreateDispatch( _T("Excel.Application") );
CWorkbooks books = app.get_Workbooks();
CWorkbook book = books.Add(covOptional);
books.get_Item(COleVariant(short(1)));
CWorksheets sheets = book.get_Sheets();
CWorksheet sheet = sheets.get_Item(COleVariant((short)1));

long lSheetCount = sheets.get_Count();
ASSERT ( 3 == lSheetCount ); // default quantity
// trying to use Add, but it failed:
sheets.Add( COleVariant(short(2)), COleVariant(short(2)),
COleVariant(short(1)), COleVariant(short(3)) ); // last param is type.
what should I put here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top