GcExcel Java enables users to add charts in spreadsheets for improved data analysis and enhanced data visualization.
Users can create and delete chart using the methods of the IShapes interface and the IChart interface
You can create chart in a worksheet by using the addChart method of the IShapes interface.
To create a chart, refer to the following example code.
Java |
Copy Code |
---|---|
// Add Chart IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 300, 10, 300, 300); worksheet.getRange("A1:D6").setValue( new Object[][] { { null, "S1", "S2", "S3" }, { "Item1", 10, 25, 25 }, { "Item2", -51, -36, 27 }, { "Item3", 52, -85, -30 }, { "Item4", 22, 65, 65 }, { "Item5", 23, 69, 69 } }); // Create Chart shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true); |
You can delete an existing chart by using the delete method of the IChart interface.
To delete a chart from your worksheet, refer to the following example code.
Java |
Copy Code |
---|---|
// Delete Chart
shape.getChart().delete(); |