Ich lese Excel-Datei 3.16 hier Apache Poi mit meinem Codewarum diese Ausnahme ist immer: Exception in thread "main" org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException
try
{
String excelPath = "C:\\Users\\wecme\\Desktop\\AccountStatement.xls";
FileInputStream fileInputStream = new FileInputStream(new File(excelPath));
// Create Workbook instance holding .xls file
XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
// Get the first worksheet
XSSFSheet sheet = workbook.getSheetAt(0);
// Iterate through each rows
java.util.Iterator<Row> rowIterator = sheet.iterator();
while (rowIterator.hasNext())
{
// Get Each Row
Row row = rowIterator.next();
// Iterating through Each column of Each Row
java.util.Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext())
{
Cell cell = cellIterator.next();
// Checking the cell format
switch (cell.getCellType())
{
case Cell.CELL_TYPE_NUMERIC:
System.out.print(cell.getNumericCellValue() + "\t");
break;
case Cell.CELL_TYPE_STRING:
System.out.print(cell.getStringCellValue() + "\t");
break;
case Cell.CELL_TYPE_BOOLEAN:
System.out.print(cell.getBooleanCellValue() + "\t");
break;
}
}
System.out.println("");
}
} catch (IOException ie)
{
ie.printStackTrace();
}
mein Excel-Daten Aussehen wie folgt aus:
Datetime Description TransactionId Credit Amount Debit Amount Remaining OdAmount EnteredBy Remarks
1/6/2017 8:14 IDEA (9542010237) COMMISSION GLGHQN 0.31 0 2721.92 0 iNHYD0390437LO IDEA COMMISSION
, wenn ich andere Datei zu lesen, die ihre Lese richtig Zeit mit Datum hat, nicht aber, wenn ich versuche, diese Datei, diese Ausnahme zu lesen kommenden
Exception in thread "main" org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException: No valid entries or contents found, this is not a valid OOXML (Office Open XML) file
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:286)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:758)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:327)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:291)
at excelRead.ReadExcel.main(ReadExcel.java:27)
bitte helfen Sie mir, danke.
'NotOfficeXmlFileException' - es eine xlsx ist erwartet, keine xls. –
Ich bin nicht völlig vertraut mit dem Lesen von Excel-Dateien, aber haben Sie versucht, es in das neuere .xlsx-Format zu konvertieren? Es ist nur eine Ahnung, also könnte ich mich irren. –
aber ich habe xls und ich möchte es nicht mit xlsx resinieren, wie kann ich das erreichen? –