[]
This tutorial shows how to visualize raw worksheet data by creating Excel charts programmatically using Document Solutions for Excel, Java Edition (DsExcel Java).
You’ll learn how to:
Add a new worksheet dedicated to charts
Insert a chart using the addChart() method
Build chart series from worksheet ranges
Format chart axes (number formats, labels)
Export a final workbook containing a rendered Excel chart
JDK 8+
DsExcel Java (JARs added to your classpath)
import com.grapecity.documents.excel.*;
import com.grapecity.documents.excel.drawing.*;First, we’ll create a workbook and add a dedicated worksheet for the chart.
Workbook workbook = new Workbook();
IWorksheet chartSheet = workbook.getWorksheets().add();
chartSheet.setName("Chart");Charts require a data range. Here we’ll add a small dataset that includes labels and values.
chartSheet.getRange("A1:D6").setValue(new Object[][] {
{null, "Q1", "Q2", "Q3"},
{"Belgium", 10, 25, 25},
{"France", -51, -36, 27},
{"Greece", 52, -85, -30},
{"Italy", 22, 65, 65},
{"UK", 23, 69, 69},
});(Optional formatting for readability)
chartSheet.getRange("B1:D1").setHorizontalAlignment(HorizontalAlignment.Right);
chartSheet.getRange("B1:D1").getFont().setBold(true);
chartSheet.getRange("B2:D6").setNumberFormat("€#,##0");Use the getShapes().addChart() method to insert a chart object into the worksheet.
IShape shape = chartSheet.getShapes()
.addChart(ChartType.ColumnClustered, 300, 10, 300, 300);
shape.getChart().getChartTitle().setText("Sales Increases Over Previous Quarter");Now connect the chart to your data range by creating a series collection from a worksheet range.
shape.getChart().getSeriesCollection()
.add(chartSheet.getRange("A1:D6"), RowCol.Columns, true, true);This tells DsExcel to treat the dataset as:
Series grouped by columns
First row contains category labels (Q1, Q2, Q3)
First column contains series names (Belgium, France, etc.)
You can format the value axis to match your dataset’s number formatting.
IAxis valueAxis = shape.getChart().getAxes().item(AxisType.Value);
valueAxis.getTickLabels().setNumberFormat("€#,##0");When you open the generated workbook in Excel, the Chart worksheet will contain:
A clustered column chart
A chart title
Multiple series (Belgium, France, Greece, etc.)
Q1/Q2/Q3 category labels
A formatted value axis using the specified currency format

workbook.save("ExcelChart.xlsx");Explore the complete chart documentation here
View our full-featured chart demos online