Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe vor, mein altes Programm up-zu-graden !

Nun aber stehe ich davor, dass ich keine xlsx Dateien öffnen kann.

meine alte API jxl ist ja nur bis MS Office 03.

Wenn ihr eine wisst, könnt ihr mir vllt gleich m,al den Link zum download schicken.=?

Wäre echt hilfreich!!! :confused:

thx

leichter gesagt, als getan ....

Also mir das jetzt mal so zusammengeschnipselt.:

File inputFile = null; // ######################

// FileInputStream fileInStream = null;

POIFSFileSystem fileInStream = null;

Workbook workbook = null;

Sheet sheet = null;

Row row = null;

Cell cell = null;

Iterator<Row> rowIterator = null;

Iterator<Cell> cellIterator = null;

int numSheets = 0;

try {

inputFile = new File("O:\\test.xlsx"); // #######################

fileInStream = new POIFSFileSystem(new FileInputStream(inputFile));

workbook = WorkbookFactory.create(fileInStream);

// XSSF or HSSFWorkbook ?

if (workbook instanceof org.apache.poi.hssf.usermodel.HSSFWorkbook) {

System.out.println("HSSFWorkbook");

} else {

System.out.println("XSSFWorkbook");

}

numSheets = workbook.getNumberOfSheets(); // number of sheets

for (int i = 0; i < numSheets; i++) { // Zählerschl. durch Formulare

sheet = workbook.getSheetAt(i); // get the sheet

rowIterator = sheet.iterator();

while (rowIterator.hasNext()) { // durch die Reihen

row = rowIterator.next();

System.out.println("Zeilennummer: " + row.getRowNum());

cellIterator = row.iterator(); // Iterator um durch die

// Zellen der Zeile zu iterieren

while (cellIterator.hasNext()) { // durch die Zellen

// iterieren

cell = cellIterator.next();

System.out.println("Cell: " + cell.toString());

}

}

}

} catch (Exception ex) {

System.out.println("Fehler gefunden !!");

System.out.println("Bezeichnung: " + ex.getClass().getName());

System.out.println("Message: " + ex.getMessage());

System.out.println("Stacktrace follows.........");

ex.printStackTrace(System.out);

} finally {

if (fileInStream != null) {

try {

((Closeable) fileInStream).close();

} catch (Exception ex) {

// I G N O R E //

}

Problem: er sagt:::

Fehler gefunden !!

Caught an: org.apache.poi.poifs.filesystem.OfficeXmlFileException

Message: The supplied data appears to be in the Office 2007+ XML. POI only supports OLE2 Office documents

Stacktrace follows.........

org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. POI only supports OLE2 Office documents

at org.apache.poi.poifs.storage.HeaderBlockReader.<init>(HeaderBlockReader.java:96)

at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:84)

at openwithxssf.main(openwithxssf.java:30)

das ist genau das, was er aber eigentlich machen sollte....

Wer kann mir DA weiterhelfen??? :confused:

das ist genau das, was er aber eigentlich machen sollte
Welche POI Version verwendest du? Die bisherigen Releases unterstützen Office 2007 nicht - und mir ist auch kein anderes Java Framework bekannt, was mit xlsx umgehen kann.

Vielleicht wirst du in der POI Beta fündig:

We are currently working to support the new Office Open XML file formats, such as XLSX and PPTX, which were introduced in Office 2007. [...] Users interested in the OOXML support should download the POI 3.5 beta 6 the source and binaries from their local mirror. People interested should also follow the dev list to track progress.

Da Du keine genaueren Bezeichnungen für Deine Komponente schreibst kämen nun mal 2 in Frage:

JExcelApi

JXL

Da Du aber wohl mit Excel arbeitest tippe ich auf erstere und dort steht auf der Seite:

Reads data from Excel 95, 97, 2000, XP, and 2003 workbooks

Dir ist doch sicherlich klar dass mit Office 2007 bzw 2008 das Dateiformat vollständig geändert hat und dass Du die bisherigen Formate so nicht mehr verwenden kannst !? Denn genau das sagt Dir auch Deine Fehlermeldung

Phil

ja das ist mir wohl klar und das habe ih ja soweit auch berücksichtigt...

benutze:

\javalibs\poi-ooxml-3.5-beta5.jar

\javalibs\poi-3.0-rc4-20070503.jar

\javalibs\poi-3.5-beta3.jar

\javalibs\ooxml-lib\xmlbeans-2.3.0.jar

also

die beinhalten doch den poixssf und das ist für ms office formate bis xml dateien(docx xlsx ....etc pp )

oder was sagt iht

alles geklappt....

thx

:bimei

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.