gpt4 book ai didi

java - 我需要用java读取xlsx文件

转载 作者:太空宇宙 更新时间:2023-11-04 13:15:38 25 4
gpt4 key购买 nike

但我收到错误。有没有什么错误。 文件 myFile = new File("D:/abhilash/L2t Tracker.xlsx"); FileInputStream fis = new FileInputStream(myFile);

        // Finds the workbook instance for XLSX file
XSSFWorkbook myWorkBook = new XSSFWorkbook (fis);

// Return first sheet from the XLSX workbook
XSSFSheet mySheet = myWorkBook.getSheetAt(0);

// Get iterator to all the rows in current sheet
Iterator<Row> rowIterator = mySheet.iterator();

// Traversing over each row of XLSX file
while (rowIterator.hasNext()) {
Row row = rowIterator.next();

// For each row, iterate through each columns
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {

Cell cell = cellIterator.next();

switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
System.out.print(cell.getStringCellValue() + "\t");
break;
case Cell.CELL_TYPE_NUMERIC:
System.out.print(cell.getNumericCellValue() + "\t");
break;
case Cell.CELL_TYPE_BOOLEAN:
System.out.print(cell.getBooleanCellValue() + "\t");
break;
default :

}
}
System.out.println("");
}

最佳答案

我得到了答案。为此,我们还需要导入 dom4j jar 和 poi ooxml 模式。我忘记了这两个文件

关于java - 我需要用java读取xlsx文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33560377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com