create excel charts in Java

Charts and graphs are used to summarize and visually represent the data. They give an insight that can further be used to make the decisions. Charts are considered to be an integral part of Excel spreadsheets and are widely used in various applications. In this article, you will learn how to generate charts programmatically from the data provided in the Excel worksheets. Particularly, the article covers how to create different types of charts in Excel using Java.

Java API to Create Excel Charts

In order to create charts in Excel files, we’ll use Aspose.Cells for Java. It is a powerful API that allows you to implement Excel automation features in your Java applications. Furthermore, it lets you generate a variety of charts within a few lines of code. You can either download the API or install it using the following Maven configurations.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-cells</artifactId>
    <version>21.6</version>
</dependency>

Supported Excel Chart Types

Aspose.Cells for Java provides a complete set of standard chart types. The list includes, but not limited to:

  • Column
  • Bar
  • Line
  • Pie
  • Scatter
  • Area
  • Doughnut
  • Radar
  • Surface 3D
  • Bubble
  • Stock
  • Cylinder
  • Cone
  • Pyramid

For more details about the supported Excel charts, visit this article.

Create a Chart in Excel using Java

The following are the steps to create a chart in an Excel file using Java.

The following code sample shows how to create a chart in Excel using Java.

Create column chart in Excel

For demonstration, lets now create some other types of charts in an Excel workbook.

Create a Line Chart in Excel using Java

The following are the steps to create a line chart in Excel using Java.

The following code sample shows how to create a line chart in Excel using Java.

Create line chart in Excel

Create a Pyramid Chart in Excel using Java

The following are the steps to create a pyramid chart in Excel using Java.

The following code sample shows how to create a pyramid chart in Excel using Java.

Create pyramid chart in Excel

Get a Free API License

You can use Aspose.Cells for Java without evaluation limitations by getting a temporary license.

Conclusion

In this article, you have seen how to create charts in Excel worksheets using Java. Particularly, you have learned how to create column, line, and pyramid charts in Excel programmatically. You can use the same method to create other types of charts in Excel worksheets. To learn more about the API, visit the documentation. In case you would have any queries, contact us via our forum.

See Also