# Create and Delete Chart

Work with DsExcel to create and delete a chart in a worksheet.

## Content



DsExcel 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](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IShapes.html) interface and the [IChart](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IChart.html) interface

## Create Chart

You can create chart in a worksheet by using the [addChart](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IShapes.html#addChart) method of the [IShapes](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IShapes.html) interface. Using this method, you can add a chart at a particular position by providing postion coordinates of the target range. The method has another overload that lets you add a chart directly to the target range. You can use **add** method of the **ISeriesCollection** class which lets you reflect data over the chart.
To create a chart, refer to the following example code.

```Java
// Add Chart
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 200, 75, 300, 300);
worksheet.getRange("A1:D6").setValue(new Object[][] {
        { null, "Revenue", "Profit", "Sales" },
        { "North", 10, 25, 25 },
        { "East", 51, 36, 27},
        { "South", 52, 85, 30 },
        { "West", 22, 65, 65 }
});
        
// Create Chart
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true);
        
//Add Chart at a particular range
// IShape shapeRange = worksheet.getShapes.addChart(ChartType.ColumnClustered, worksheet.getRange["A8:E20"]);
//shapeRange.getChart().getSeriesCollection().add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);
```

![](https://cdn.mescius.io/document-site-files/images/dd59ea42-cd61-4fa6-a018-6231c2a9c598/images/create-chart.png)

> !type=note
>
> **Note**: The target range and the linked picture to be added must exist in the same worksheet. Otherwise, it results into an **InvalidOperationException**.

## Delete Chart

You can delete an existing chart by using the [delete](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IChart.html#delete) method of the [IChart](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IChart.html) interface.
To delete a chart from your worksheet, refer to the following example code.

```Java
// Delete Chart
shape.getChart().delete();
```
