java - how to retrieve specific chart in power point slide using apache POI -
i have power point slide has multiple charts (multiple bar , line chart) need update them using apache poi library. far used have 1 chart per slide , used chart using below code identify , update values.
xslfchart chart = null; for(poixmldocumentpart part : mainslide.getrelations()){ if(part instanceof xslfchart){ chart = (xslfchart) part; break; } }
not sure how identify specific chart dont see method identify shape
for(xslfslide slide:ppt.getslides()){ (xslfshape shape : slide.getshapes()) { if (shapename.equals(shape.getshapename())) return slide; } }
i gave name table,textbox in powerpoint , can retrieve in code using shapename dont see chart . can 1 me plz?
i figured out way identify of office mate.
first give title chart in power point open layout> chart title> above chart give name . hide title keep font size small , make font color white .
add code in java below
private xslfchart getchartobject(xslfslide mainslide,string chartname) throws ioexception { xslfchart chart = null; for(poixmldocumentpart part : mainslide.getrelations()){ if(part instanceof xslfchart){ chart = (xslfchart) part; if(chart.getctchart().gettitle()!=null && chart.getctchart().gettitle().gettx()!=null){ if(chart.getctchart().gettitle().gettx().getrich().getplist().get(0).getrlist().get(0).gett().equals(chartname)) break; } } } return chart; }
Comments
Post a Comment