[英]Resizing a XSLFChart
When creating a XSLFChart
on a XSLFSlide
, I can't seem to get the anchoring to work as intended.在
XSLFChart
上创建XSLFSlide
时,我似乎无法按预期进行锚定。 I'm generate the chart as follows我生成图表如下
XSLFSlide slide = ppt.createSlide();
XSLFChart chart = ppt.createChart(slide);
slide.addChart(chart, new Rectangle(200, 200, 200, 200));
// Further styling and data
But when I open the Powerpoint, the chart is scrunched up in the top left corner, as if it was anchored with a Rectangle
at (0, 0) with a height and width of 0. Creating the chart with the other overload of the function ( addChart(XSLFChart)
) also creates it in the corner, but with some height and width.但是当我打开 Powerpoint 时,图表在左上角被揉成一团,就好像它被一个位于 (0, 0) 且高度和宽度都为 0 的
Rectangle
锚定了一样。使用函数的另一个重载创建图表( addChart(XSLFChart)
) 也在角落创建它,但有一些高度和宽度。
The position of the XSLFChart
needs to be set in measurement unit English Metric Units EMU
, not in points as for other anchors of XSLFSimpleShape
. XSLFChart
的位置需要设置为度量单位 English Metric Units EMU
,而不是像XSLFSimpleShape
的其他锚点那样设置为点。 There is org.apache.poi.util.Units to convert between different other units (points also) and EMU
.有org.apache.poi.util.Units可以在不同的其他单位(也指)和
EMU
之间进行转换。
In your case:在你的情况下:
XSLFSlide slide = ppt.createSlide();
XSLFChart chart = ppt.createChart(slide);
Rectangle rect = new Rectangle(200*Units.EMU_PER_POINT, 200*Units.EMU_PER_POINT, 200*Units.EMU_PER_POINT, 200*Units.EMU_PER_POINT);
slide.addChart(chart, rect);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.