Microsoft® Excel File Charts Conversion and Creation via Java

Convert Excel document charts to images as well as create various charts using server-side APIs within Java based applications.


Analysing data via charts shows the bigger picture and it is easy to make more informed decisions with clearer insights. Java Excel Library supports drawing different chart creation listed by ChartType including pie, pyramid, line and bubble charts. Moreover, it also converts charts to images. API provides a Charts class for representing a single Excel chart.

Convert Excel Charts to Images

Process of converting charts to images including JPG, PNG, TIFF, BMP etc is, Use the Workbook class to load the Excel file, select the relevant workseet containing the charts or iterate through each chart in each worksheet. Define ImageOrPrintOptions and render output image of the Chart using Chart.toImage .

Java Code to Convert Excel Chart to Image

Create Charts within Excel File

Creating charts using Excel API is simple, as API provides set of different classes such as Axis, Chart, ChartArea, ChartDataTable, ChartFrame, ChartPoint, ChartPointCollection, ChartCollection etc for different kinds of charts. Process is, Create Workbook class object and select the first worksheet or the relevant sheet by providing its index. For data source of the chart, insert values to worksheet cells using setValue method. Use ChartCollection collection’s add method to add the chart, define type of chart with the ChartType enumeration. Access the new Chart object from the ChartCollection collection by passing its index. Use the SeriesCollection charting object to specify the chart’s data source.

Java Code to Create Excel Charts