gpt4 book ai didi

java - 如何使用 apache poi 获取 pptx 幻灯片注释文本?

转载 作者:搜寻专家 更新时间:2023-11-01 01:52:07 24 4
gpt4 key购买 nike

到目前为止,我只有一个用于从 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 < 1) {
System.out.println("null");
} else {
for (TextRun run : runs) {
System.out.println(" > " + 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) {

}

关于java - 如何使用 apache poi 获取 pptx 幻灯片注释文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24873725/

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