2012-04-26 63 views
5

是否可以使用Apache POI以編程方式創建的PowerPoint幻燈片添加註釋?使用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(); 

...返回null。

是否有另一種方法來創建必要的筆記對象,也許使用我沒有找到的工廠類?

或者,有沒有另一種方式來添加筆記到不涉及Note類的幻燈片?

回答

7

問題是很古老,但我希望這個答案會幫助別人。使用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 
    [...] 
+0

這是行得通的。謝謝! – GBP 2016-09-26 11:31:38

0

在最新版本中不支持添加PowerPoint筆記。

+1

它可能不會太難,雖然添加的功能,如果有人有興趣自願做的工作!所有的記錄支持都存在,它只需要在用戶模型代碼 – Gagravarr 2012-04-26 16:55:46

+0

中以正確的順序進行接線。我沒有太多時間,但是可能獎勵會是一個很好的激勵。 – eabraham 2012-04-26 20:31:31

+0

這個答案已經過時 – 2018-01-18 08:37:43

相關問題