是否可以向使用Apache POI编程创建的powerpoint幻灯片添加备注?
这是我到目前为止所知道的
Slide slide = ppt.createSlide();
org.apache.poi.hslf.record.Notes notesRecord = new ???; // <--- No Public constructor
org.apache.poi.hslf.model.Notes noteModel = new org.apache.poi.hslf.model.Notes(notesRecord ); // <--- Only one constructor which takes a org.apache.poi.hslf.record.Notes
// hopefully make some notes
// add the notes to the slide
slide.setNotes(noteModel);正如您所看到的,似乎没有一种方法可以创建向幻灯片对象添加注释所需的对象。
呼叫
Notes notesSheet = slide.getNotesSheet();...returns为空。
有没有其他方法可以创建必要的notes对象,比如使用我没有找到的工厂类?
或者,有没有其他方法可以向幻灯片添加注释,而不涉及使用note类?
发布于 2015-06-11 21:07:37
这个问题已经很老了,但我希望这个答案能对某些人有所帮助。使用Apache POI 3.12,以下代码应将一些文本作为注释添加到幻灯片中:
// create a new empty slide show
XMLSlideShow ppt = new XMLSlideShow();
// add first slide
XSLFSlide slide = ppt.createSlide();
// get or create notes
XSLFNotes note = ppt.getNotesSlide(slide);
// insert text
for (XSLFTextShape shape : note.getPlaceholders()) {
if (shape.getTextType() == Placeholder.BODY) {
shape.setText("String");
break;
}
}
// save
[...]https://stackoverflow.com/questions/10336111
复制相似问题