更改图表位置和大小

Aspose.Cells - 更改图表位置和大小

要更改图表的位置(X、Y坐标)和大小(高度、宽度),使用Aspose.Cells中的这些属性:

  1. Chart.getChartObject().get/setWidth()
  2. Chart.getChartObject().get/setHeight()
  3. Chart.getChartObject().get/setX()
  4. Chart.getChartObject().get/setY()

Java

 Workbook workbook = new Workbook(dataDir + "AsposeChart.xls");

Worksheet worksheet = workbook.getWorksheets().get(0);

//Load the chart from source worksheet

Chart chart = worksheet.getCharts().get(0);

//Resize the chart

chart.getChartObject().setWidth(400);

chart.getChartObject().setHeight(300);

//Reposition the chart

chart.getChartObject().setX(250);

chart.getChartObject().setY(150);

下载运行代码

下载示例代码