java 如何提取表格数据,如Excel表格单元格和表格行数据从PPT中的Apache POI

9rnv2umw  于 2023-08-01  发布在  Java
关注(0)|答案(1)|浏览(125)

我目前正在使用Apache POI解析PPTX文档,并能够从PPT幻灯片XSLFSlide中提取图像,嵌入式OLE对象,但不知道如何从幻灯片中提取嵌入式xls表。我需要帮助尝试解析和读取嵌入式xls表在PPT幻灯片。

gab6jxml

gab6jxml1#

try (FileInputStream inStream = new FileInputStream(new File("path/to/file.xlsx"))) {
   XSSFWorkbook workbook = new XSSFWorkbook(inStream);
   XSSFSheet sheet = workbook.getSheetAt(0);

   for (Iterator<Row> rowIterator = sheet.iterator() ; rowIterator.hasNext(); ) {
      Row row = rowIterator.next();
      for (Iterator<Cell> cellIterator = row.cellIterator(); cellIterator.hasNext(); )  {
         Cell cell = cellIterator.next();
         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;
            ...   
         }
      }
      System.out.println("");
   }
}

字符串

相关问题