如何格式化图例集阴影预设外部whit apache poi

问题描述 投票:0回答:1

我需要使用 apache poi 和 java 格式化 Excel,如下所示,但我不知道如何使用 Apache POI 格式化图例。谁能帮我格式化吗?谢谢大家。 (https://i.stack.imgur.com/KPkL5.png)

我已经尝试过,但我不知道该怎么做。

apache-poi
1个回答
0
投票

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);
...
© www.soinside.com 2019 - 2024. All rights reserved.