本文介绍了如何使用Apache POI获得PPTX格式幻灯片备注文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
到目前为止,我只有一个工作code,用于从PPT幻灯片注释文本
So far I only have a working code for retrieving texts from ppt slide notes
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 < 1) {
System.out.println("null");
} else {
for (TextRun run : runs) {
System.out.println(" > " + run.getText());
}
}
}
} catch (IOException ioe) {
}
但你如何从PPTX格式幻灯片备注文本检索?
But how do you retrieve text from pptx slide notes?
推荐答案
不断试错后,找到了解决办法。
After constant trial and error, found a solution.
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获得PPTX格式幻灯片备注文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!