Datenbank in Exceltabelle exportieren?
-
Hallo.
Ich habe eiune Paradoxdatenbank undmöchte die Daten in der Tabelle oder wenn möglich die Tabelle an sich in eine Exceltabelle exportieren. Wie kann ich das tun? Welche Komponenten benötige ich? Ich habe nochnie mit Exceltabellen in Cü++ zu tun gehabt. Danke für eure Hilfe.
MfG Windoof
-
Hallo
WOZU gibt es wohl die FAQ

MfG
Klaus
-
Da hab ich schon was gefunden aber es funzt nicht. Hab es schon umgeformt, etc. er meldetauchkeine Fehler, aber er speichert keine .xls-Datei ab...
void __fastcall TMainForm::Query1AfterOpen(TDataSet *DataSet) { SaveToExcel(tKasse); } void __fastcall TMainForm::SaveToExcel(TTable *pQuery) { Variant Excel; try { Excel = GetActiveOleObject("Excel.Application"); } catch(...) { Excel = CreateOleObject("Excel.Application"); } // Excel.OlePropertySet("Visible", true); try { Variant WorkBooks = Excel.OlePropertyGet("WorkBooks"); WorkBooks.OleFunction("Add"); Variant ActiveWorkBook = Excel.OlePropertyGet("ActiveWorkbook"); Variant WorkSheets = Excel.OlePropertyGet("Worksheets"); Variant WorkSheet = WorkSheets.OlePropertyGet("Item", 1); WorkSheet.OleFunction("Activate"); pQuery->First(); int iRow=0; while(!pQuery->Eof) { for (int iCol = 0; iCol < pQuery->Fields->Count; ++iCol) { Variant Range=WorkSheet.OlePropertyGet("Cells",iRow+1,iCol+1); Range.OlePropertySet("Value",pQuery->Fields->Fields[iCol]->AsString); } ++iRow; pQuery->Next(); } ActiveWorkBook.OleFunction("SaveAs",ExtractFilePath(ParamStr(0))+"KV_"+StringReplace(StringReplace(DateToStr(Date()),".","",TReplaceFlags()<<rfReplaceAll),"/","",TReplaceFlags()<<rfReplaceAll)+".xls"); } catch(...) { } Excel.OleFunction("Quit"); Excel = Unassigned; }
-
wie wärs wenn du einfach das ganze semikolongetrennt in eine csv-datei speichern würdest?
ist, glaube ich, ein relativ schneller weglg hagbard
-
Nein, es muss eine Excel-Tabellesein.
-
Also soviel hab ich bisher herausgefunden: Der Fehler liegt in dieser Zeile:
Variant ActiveWorkBook = Excel.OlePropertyGet("ActiveWorkbook");Fehlermeldung:
Falscher Variablentyp
Welcher Datentyp muss es denn sein? Bzw. was muss ich tun, damit er die Fehlermeldung nichtmehr bringt und er endlich Excel-Tabellen abspeichert?
MfG Windoof
-
Windoof schrieb:
Nein, es muss eine Excel-Tabellesein.
CSV-Dateien werden automatisch in Excel erkannt und geoeffnet. Ist meiner Meinung nach der schnellere Weg.
-
Stimmt, sorry
Danke für deine Hilfe, wieso bin ich nicht drauf gekommen... *fg*