我需要使用 apache poi 和 java 格式化 Excel,如下所示,但我不知道如何使用 Apache POI 格式化图例。谁能帮我格式化吗?谢谢大家。 ()
我已经尝试过,但我不知道该怎么做。
A XDDFChartLegend 具有方法
org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties getShapeProperties()
和 void setShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties properties)
。这些 CTShapeProperties
可能具有填充属性,可能是具有 RGB 颜色集的固体填充。
示例:
...
XDDFChartLegend legend ...
...
org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties shapeProperties = legend.getShapeProperties();
if (shapeProperties == null) shapeProperties = org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties.Factory.newInstance();
if (shapeProperties.getSolidFill() == null) shapeProperties.addNewSolidFill();
if (shapeProperties.getSolidFill().getSrgbClr() == null) shapeProperties.getSolidFill().addNewSrgbClr();
shapeProperties.getSolidFill().getSrgbClr().setVal(new byte[]{0,(byte)255,0});
System.out.println(shapeProperties);
legend.setShapeProperties(shapeProperties);
...