Hallo,
ich möchte mit COM4J Textinhalte aus MS-Office Dokumenten (doc, xls, ppt) extrahieren. Dabei habe ich folgendes Problem. Wenn ich vor der Extraktion eines MS-Word Dokuments eine Excel Datei extrahiere, bekomme ich folgenden Fehler:
Der Fehler tritt beim öffnen des Dokuments auf.
Extrahiere ich zuerst ein MS-Word Dokument klappt alles wunderbar.
Hier die Codesnippets für das öffnen der Dokumente:
MS-Word:
Excel:
Google hat mich zu diesem Thema auch nicht weiter gebracht, evtl. könnt ihr mir ja helfen.
ich möchte mit COM4J Textinhalte aus MS-Office Dokumenten (doc, xls, ppt) extrahieren. Dabei habe ich folgendes Problem. Wenn ich vor der Extraktion eines MS-Word Dokuments eine Excel Datei extrahiere, bekomme ich folgenden Fehler:
Java:
com4j.ComException: 80020005 Typkonflikt. : Typkonflikt. : .\invoke.cpp:460
Extrahiere ich zuerst ein MS-Word Dokument klappt alles wunderbar.
Hier die Codesnippets für das öffnen der Dokumente:
MS-Word:
Java:
...
_Application app = null;
_Document doc = null;
Variant _ = null;
if((app = word.ClassFactory.createApplication()) == null) {
throw new Exception("can't create application");
}
app.visible(true);
_ = Variant.MISSING;
if((doc = app.documents().open(_file.getAbsolutePath(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, _, _, Boolean.TRUE, _, _, WdOpenFormat.wdOpenFormatAuto, MsoEncoding.msoEncodingAutoDetect, _, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, _)) == null) {
throw new Exception("can't open document");
}
...
Java:
...
excel._Application app = null;
_Workbook workBook = null;
Variant _ = null;
if((app = excel.ClassFactory.createApplication()).application() == null) {
throw new Exception("can't create application");
}
app.visible(0, true);
app.displayAlerts(0, false);
app.userControl(false);
_ = Variant.MISSING;
if((workBook = app.workbooks().open(_file.getAbsolutePath(), Boolean.FALSE, Boolean.TRUE, Integer.valueOf(5), _, _, _, XlPlatform.xlWindows, _, Boolean.FALSE, Boolean.FALSE, _, Boolean.FALSE, _, _, 0)) == null) {
throw new Exception("can't open workbook");
}
...
Zuletzt bearbeitet: