我有一个pptx,其中包含以下幻灯片布局:
System.out.println("Available slide layouts:");
for(XSLFSlideMaster master : ppt.getSlideMasters()){
for(XSLFSlideLayout layout : master.getSlideLayouts()){
System.out.println("Name: "+layout.getName()+" Type: "+layout.getType());
Available slide layouts:
Name: Content Type: OBJ_ONLY
Name: Title and 4 Content Type: FOUR_OBJ
Name: Title Only Type: TITLE_ONLY
Name: DETAIL_SCORECARD Type: CUST
Name: Scorecard Type: CUST
Name: CSCLayout1 Type: CUST
Name: 1_Blank Type: BLANK
Name: Title, Content, and 2 Content Type: OBJ_AND_TWO_OBJ
Name: Title and Content Type: TITLE_AND_CONTENT
Name: Title, Text, and Content Type: TX_AND_OBJ
Name: Two Content Type: TWO_OBJ
Name: Main Type: TITLE
如何选择第二或第三个CUST布局选项
当前实施适用于第一个CUST幻灯片布局
FileInputStream input = null;
input = new FileInputStream(filename);
slideshow = new XMLSlideShow(input);
XSLFSlideMaster defaultMaster = slideshow.getSlideMasters()[0];
XSLFSlideLayout detailedscorecard = defaultMaster.getLayout(SlideLayout.CUST);
我已经尝试在幻灯片母版中重命名幻灯片名称,但它似乎对上面的列表没有任何影响。有没有办法使用layout.getName()来查找幻灯片布局的实际名称,
XSLFSlideLayout detailedscorecard = defaultMaster.getLayout(SlideLayout.CUST);
答案 0 :(得分:3)
好的..从朋友那里得到了答案并得到了解决......
XSLFSlideLayout detailedscorecard = null;
for (XSLFSlideMaster master : slideshow.getSlideMasters()){
for (XSLFSlideLayout layout1 : master.getSlideLayouts()){
if (layout1.getName().equals("Scorecard")) {
detailedscorecard=layout1;
}
}
}