mit vc++ auf ne excel tabelle zugreifen
-
ja ne steht ja schon oben das problem
thx schonmal für eure hilfe
-
eventuell hilft dir das
#import <mso9.dll> no_namespace rename("DocumentProperties", "DocumentPropertiesXL") #import "C:\Programme\Gemeinsame Dateien\Microsoft Shared\VBA\VBA6\vbe6ext.olb" no_namespace #import <excel9.olb> rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") rename("DocumentProperties", "DocumentPropertiesXL") no_dual_interfaces #pragma warning (disable:4192) #pragma warning (disable:4146) #include <stdio.h> #include <tchar.h> void dump_com_error(_com_error &e) { _tprintf(_T("Oops - hit an error!\n")); _tprintf(_T("\a\tCode = %08lx\n"), e.Error()); _tprintf(_T("\a\tCode meaning = %s\n"), e.ErrorMessage()); _bstr_t bstrSource(e.Source()); _bstr_t bstrDescription(e.Description()); _tprintf(_T("\a\tSource = %s\n"), (LPCTSTR) bstrSource); _tprintf(_T("\a\tDescription = %s\n"), (LPCTSTR) bstrDescription); } struct StartOle { StartOle() { CoInitialize(NULL); } ~StartOle() { CoUninitialize(); } } _inst_StartOle; void main() { using namespace Excel; _ApplicationPtr pXL; try { if (pXL.GetInterfacePtr() == NULL) pXL.CreateInstance(L"Excel.Application.9"); //check ob es schon laeuft pXL->Visible = VARIANT_TRUE; // pXL->Visible = VARIANT_FALSE; WorkbooksPtr pBooks; _WorkbookPtr pBook; WorksheetsPtr pSheets; _WorksheetPtr pSheet; pBooks= pXL->Workbooks; pBook = pBooks->Add((long)Excel::xlWorksheet); //vohandenes Dokument mit pBooks->Open("c:\\test.xls"); öffnen pSheets = pBook->GetWorksheets(); // pSheets->Add(); //Blatt hinzufuegen pSheet=pBook->ActiveSheet; pSheet->Name="test"; //Blattname ändern //pSheets->Delete(); //Blatt löschen double q=354.6; pXL->Range["test!A7"]->Value2=q; pXL->Range["test!A8"]->Value2=q+3; pXL->Range["test!A9"]->Formula="=Sum(A7:A8)"; //bei Formeln englische Namen verwenden sonst Problem // pXL->Range["test!D26"]->Formula="=Var(D20:D24)"; // pXL->Range["test!D27"]->Formula="=Average(D20:D24)"; pXL->Range["test!B7"]->Value2="20.03.2003"; pXL->Range["test!B8"]->Value2="13:50"; pXL->Range["test!A7:test!A9"]->Font->Bold = true; //Fett schreiben // pBook->Save(); // wenn mit open geöffnet //saveas funzt bei mir nicht so kann man das umgehen pBook->SaveCopyAs("c:\\test.xls"); pBook->Close(false); //damit der die aktuelle nicht speichert pXL->Quit(); } catch(_com_error &e) { dump_com_error(e); } }
-
#import <mso9.dll> no_namespace rename("DocumentProperties", "DocumentPropertiesXL")woher bekomm ich eine mso9.dll (microsoft office 9?)
ich hab office 2003. da heißt die vl anders!
kann mir jemand helfen?
-
vermutlich heisst das teil dann mso10.dll
-
Geht aber auch mit ODBC
-
hmm das hab ich auch schon mal probiert aber da kann man das teil doch wirklich nur datenbanklike ansprechen oder?
also ich kann ihm nicht sagen setze mal zelle B37 auf 5 usw...
oder geht das damit auch?
-