COM4J und MS-Office

jbo75

Mitglied
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:
Java:
com4j.ComException: 80020005 Typkonflikt. : Typkonflikt. : .\invoke.cpp:460
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:
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");
}
...
Excel:
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");
}
...
Google hat mich zu diesem Thema auch nicht weiter gebracht, evtl. könnt ihr mir ja helfen.
 
Zuletzt bearbeitet:

jbo75

Mitglied
evtl. sollte ich noch erwähnen, das die mehrfachen Extraktionen in einer JVM stattfinden. Also sie wird nicht immer wieder neu gestartet. Wenn dem so wäre hätte ich all diese Probleme nicht. Das ganze läuft dann im JBoss.
 

Ähnliche Java Themen

Neue Themen


Oben