Chart data table refers to a grid displaying source data of the chart and is drawn beneath the chart. The data table along with the chart is an organized form for reading exact values especially when data labels are difficult to read or are not set.
DsExcel Java allows you to insert data table beneath chart by using setHasDataTable method of the IChart interface. You can display data tables for the Column, Line, Bar, and Area chart by setting the setHasDataTable method to true. However, for any other chart types, the method returns false.
Once a data table is added, you can configure the same by using various methods of the IDataTable interface. The interface provides setHasBorderHorizontal, setHasBorderVertical and setHasBorderOutline methods to display the cell borders and table outline respectively. You can configure the fill and line style of data table by using the getFormat method.
To remove the data table of a chart, you can call delete method of the IDataTable interface.
Refer to the following example code to add and configure a chart data table in DsExcel:
C# |
Copy Code |
---|---|
//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); |
Limitation
Chart data table cannot be exported to JSON, PDF, HTML or image format.