POI 在 word中 画图
使用了poi4.10 版本 支持在word 中画图
参考了
https://blog.csdn.net/u014427811/article/details/100771314 文档写的
但是发现图例不更新 参考了 poi在excel 中画图的例子 然后在word 中 进行了代码成功 ,
以下代码是参考 poi 在excel 中写的
public static void setLegend(CTChart ctChart ){
CTLegend ctLegend = ctChart.addNewLegend();
ctLegend.addNewLegendPos().setVal(STLegendPos.B);
ctLegend.addNewOverlay().setVal(false);
}
private static void setLegend(String str, CTSerTx ctSerTx) {
if (str.contains("$"))
// set legend by str ref
ctSerTx.addNewStrRef().setF(str);
else
// set legend by str
ctSerTx.setV(str);
}
CTBarSer ser = ((CTBarChart) typeChart).getSerArray(i);
CTStrRef ctStrRef = ser.addNewTx().addNewStrRef();
setLegend(titleArr.get(i+position), ser.addNewTx());
现在poi的图例数目必须和魔板中的一样 如果不一样 不会成功 后边有遇到类似的项目在调研吧
新版本的word不能进行这个图例 但是在wps 中是可以的 奇怪