Extracting Excel2007 data from structured Storage


Joined
Apr 12, 2011
Messages
3
Reaction score
0
Hi there,

I have Excel2007 data in a CAD file as embedded object. I need to extract the Spreadsheet and save the copy as in xlsx or xls(97-2003) format.

I have handle to the storage(IStoragePtr). Am using OleLoad method to load it as OleObject and assigns it to Excel::_WorkbookPtr like,

h = ::OleLoad(storage, IID_IOleObject, site, (void **)&oleObject);

Excel::_WorkbookPtr wkbk = oleObject;

am saving copy of this workbook as,

wkbk->Activate();

wkbk->SaveAs(fileName, Excel::XlFileFormat::xlOpenXMLWorkbook,vtMissing,vtMissing,vtMissing,vtMissing,Excel::xlNoChange,vtMissing);



The above code creates xlsx file, but on open, there is no worksheet. But If i call DoVerb method on OleObject below code before SaveAs like below, Its working fine.





h = ::OleLoad(storage, IID_IOleObject, site, (void **)&oleObject);

h = oleObject->DoVerb(OLEIVERB_SHOW, NULL, context->site, 0, NULL, NULL);

Excel::_WorkbookPtr wkbk = oleObject;

and SaveAs method...



DoVerb method launches excel application. I dont want to that. I also tried passing OLEIVERB_HIDE to DoVerb method. But even it creates empty worksheet in that case.

Please let me know is there anyway to extract the OOXML data from embedded object without launching Excel application?



Thanks,
Anandh
 
Ad

Advertisements


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