je suis en train de lire le fichier Excel à l'aide ici poi 3,16 apache est mon codepourquoi cette exception reçois: Exception dans le thread "principal" 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();
}
mes regards de données Excel comme ceci:
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
quand je lis un autre fichier qui est de ne pas avoir le temps avec la date de sa lecture correctement, mais lorsque je tente de lire ce fichier cette exception à venir
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)
aidez-moi s'il vous plaît, merci.
'NotOfficeXmlFileException' - il est un xlsx attendant, pas xls. –
Je ne suis pas totalement familier avec la lecture de fichiers Excel, mais avez-vous essayé de le convertir au format .xlsx plus récent? Ce n'est qu'une intuition, alors j'ai peut-être tort. –
mais j'ai xls et je ne veux pas ré-enregistrer l'agin avec xlsx, comment puis-je y parvenir? –