[]
        
(Showing Draft Content)

数据表

图表数据表是指显示图表源数据的表格,绘制在图表下方。图表数据表是一种有组织的表格,用于显示精确值,尤其是当数据标签难以读取或未设置时。



GcExcel Java允许您使用IChart接口的setHasDataTable方法在图表下方插入数据表。通过将setHasDataTable方法设置为true,可以显示柱形图、直线图、条形图和面积图的数据表。但是,对于任何其他图表类型,该方法返回false。

添加数据表后,可以使用IDataTable接口中的各种方法配置数据表。界面提供了setHasBorderHorizontalSetHasBurderVerticalsetHasBorderOutline方法,分别显示单元格边框和表格轮廓。可以使用getFormat方法配置数据表的填充和行样式。


要删除图表的数据表,可以调用IDataTable接口的delete方法。


参考以下示例代码在 GcExcel 中添加和配置图表数据表:

//Create chart.
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 250, 0, 350, 250);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:C3"));
shape.getChart().getChartTitle().setText("Estimated vs Actual");

//Display the data table.
shape.getChart().setHasDataTable(true);

//Config the data table.
IDataTable datatable = shape.getChart().getDataTable();
datatable.getFormat().getLine().getColor().setObjectThemeColor(ThemeColor.Accent6);
datatable.getFont().getColor().setObjectThemeColor(ThemeColor.Accent2);
datatable.getFont().setSize(9);

限制


图表数据表不能导出为JSON、PDF、HTML或图片。