如何使用apache poi获取pptx幻灯片备注文本?
到目前为止,我只有一个工作代码,用于从ppt幻灯片笔记中检索文本
try { FileInputStream is = new FileInputStream("C:\\sample\\test.ppt"); SlideShow ppt = new SlideShow(is); Slide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { System.out.println(i); TextRun[] runs = slide[i].getNotesSheet().getTextRuns(); if (runs.length " + run.getText()); } } } } catch (IOException ioe) { }
但是如何从pptx幻灯片笔记中检索文本?
经过不断的反复试验,找到了解决方案。
try { FileInputStream fis = new FileInputStream("C:\\sample\\sample.pptx"); XMLSlideShow pptxshow = new XMLSlideShow(fis); XSLFSlide[] slide2 = pptxshow.getSlides(); for (int i = 0; i < slide2.length; i++) { System.out.println(i); try { XSLFNotes mynotes = slide2[i].getNotes(); for (XSLFShape shape : mynotes) { if (shape instanceof XSLFTextShape) { XSLFTextShape txShape = (XSLFTextShape) shape; for (XSLFTextParagraph xslfParagraph : txShape.getTextParagraphs()) { System.out.println(xslfParagraph.getText()); } } } } catch (Exception e) { } } } catch (IOException e) { }
- 如何使用Apache POI为docx文件中的段落设置标题样式?
- 使用Apache POI读取Excel .XLSX时出错
- 如何将excel中的值存储到java中的某些集合
- 使用Apache POI读取xlsx文件时获取exception(org.apache.poi.openxml4j.exception – 无内容类型)?
- 如何将货币类型设置为POI中的列
- 使用Apache POI创建.xlsx文件时的java.lang.NoClassDefFoundError
- 无法在Apache WorkbookFactory上找到close()方法
- apache poi excel大自动列宽
- 如何使用Apache POI XSSF创建从右到左对齐的工作表