Excel Datei Laden
-
Ein herzliches Hallo.
ich bin gerade dabei ein Excelsheet zu öffnen.
Der Code dafür sieht wie folgt aus:
void excel::RunExcel(System::String ^sPath, bool bVisible/*=true*/) { // New Excel Application sPath->Format("L:\\Wifi\\Verrechnungssystem\\_excel\\Abrechnung 2009-05.xls"); System::Object^ wb; Excel::Application^ pxlApp = gcnew Excel::ApplicationClass(); // Add a Workbook Excel::Workbook^ pWb; pxlApp->Workbooks->Add(System::Type::Missing); pWb->Open(wb,sPath); //4. Assign the Active Worksheet to a variable Excel::Worksheet^ ws = static_cast<Excel::Worksheet^>(pxlApp->ActiveSheet); pxlApp->Visible = bVisible; return; }
Mein Problem liegt darin, dass ich mit
pWb->Open(wb,"F:\\Verrechnungssystem\\_excel\\Abrechnung 2009-05.xls");
kein existierendes Excel öffnen kann, sondern immer eine Fehlermeldung bekomme:
[quote]1>------ Build started: Project: FIBU, Configuration: Debug Win32 ------
1>Compiling...
1>excel.cpp
1>.\excel.cpp(22) : error C3728: 'event Microsoft::Office::Interop::Excel::WorkbookEvents_OpenEventHandler ^Microsoft::Office::Interop::Excel::WorkbookEvents_Event::Open': event does not have a raise method
1>Build log was saved at "file://l:\Wifi\Verrechnungssystem\Projekt\Verrechnungssystem\FIBU\FIBU\Debug\BuildLog.htm"
1>FIBU - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========[/quote]Hat jemand hier ne Idee?
Vielen Dank
-
Hallo,
Excel::Workbook^ pWb;
wird nichts zugewiesen, was erste Voraussetzung für ein Funktionieren ist.
und dann einfach verwendet (was ist wb?):
pWb->Open(wb,sPath);
Richtiger wäre:
Excel::Workbook^ pWb = exApp->Workbooks->Add(Type::Missing);
MfG,
Probe-Nutzer
-
Danke erstemal für die Antwort.
Und wie kann ich dann eine existierende Exceldatei öffnen?
Weil hier starte ich ja nur das Programm (ohne Ihnhalt)
-
Sollte ungefähr so:
Excel::Workbook^ pWb; Excel::Workbooks^ wbs = pxlApp->WorkBooks; pWb = wbs->Open("F:\\Verrechnungssystem\\_excel\\Abrechnung 2009-05.xls"); ...
gehen.
MfG,
Probe-Nutzer