mfc class
-
nope :) But this link will help you achieve your task [^]
Величие не Бога может быть недооценена.
-
nope :) But this link will help you achieve your task [^]
Величие не Бога может быть недооценена.
try . odbc
:~ Failure is Success If we learn from it!!:~
-
Genarate wrapper classes for Excel type library. Select 'MFC class from TypeLib' option while adding a class. Select 'From file' radio btn and browse for excel type library. For MsOffice 2003 & 2007 type library is in Excel.Exe itself, for older versions it may vary. see how to use the generated classes http://support.microsoft.com/kb/186122[^]
-
Genarate wrapper classes for Excel type library. Select 'MFC class from TypeLib' option while adding a class. Select 'From file' radio btn and browse for excel type library. For MsOffice 2003 & 2007 type library is in Excel.Exe itself, for older versions it may vary. see how to use the generated classes http://support.microsoft.com/kb/186122[^]
-
but problem is that it always open new file I want to read data from a excel which is already open
Trioum
don't worry as long as there is GetActiveObject() API, u can get the running instance of excel and handle the sheets already opened in it :) . Have a look at http://support.microsoft.com/kb/238975 and http://support.microsoft.com/kb/196776
modified on Wednesday, March 17, 2010 10:54 AM
-
don't worry as long as there is GetActiveObject() API, u can get the running instance of excel and handle the sheets already opened in it :) . Have a look at http://support.microsoft.com/kb/238975 and http://support.microsoft.com/kb/196776
modified on Wednesday, March 17, 2010 10:54 AM
-
Still doing lot of r&d I am not able to get that excel object to read values of cells
Trioum
-
Try this one , is very good class ( created with MFC )
-
CoInitialize(NULL); HRESULT hr; CLSID clsidExcelApp; // get CLSID of Excel Application hr = CLSIDFromProgID(L"Excel.Application", &clsidExcelApp); IUnknown *pUnk = 0; // get running object that has been registered with OLE. hr = GetActiveObject(clsidExcelApp, NULL, &pUnk); if(SUCCEEDED(hr)) { IDispatch *pDisp = 0; hr = pUnk->QueryInterface(IID_IDispatch, (void**)&pDisp); //use class wizard generated excel type lib classes.. CApplication oApp(pDisp); CWorkbooks oBooks = oApp.get_Workbooks(); CWorkbook oBook = oBooks.get_Item(COleVariant((short)1)); //First workbook CWorksheets oSheets = oBook.get_Worksheets(); CWorksheet oSheet = oSheets.get_Item(COleVariant((short)1)); //First work sheet oSheet.Activate(); CRange oRange = oSheet.get_Range(COleVariant(CString(L"A1")), COleVariant(CString(L"A1"))); //cell A1 COleVariant var = oRange.get_Text(); MessageBox(var.bstrVal, L"Text in cell A1"); } doesn't work? :doh: