This tutorial explains the process to convert Excel chart to image using Java REST API. You will learn to automatically transform an Excel chart to image using Java-based API through a Java-based Cloud SDK. It will assist you in creating output images in multiple formats as per your requirements.
Prerequisite
- Create an account and get API credentials for converting charts to image
- Download Aspose.Cells Cloud SDK for Java to create graph picture
- Setup Java project with the above SDK
Steps to Convert Excel Chart to High Resolution Image using Java RESTful Service
- Define the client ID, client secret, and API base URL required to authenticate with the Aspose.Cells Cloud service
- Instantiate the CellsApi class using the provided credentials and API URL to prepare for sending requests to Aspose services
- Set the path of the Excel file that contains the chart to be converted
- Prepare a request to upload the local Excel file to Aspose Cloud’s storage and execute it
- Create a request specifying the file name, worksheet name, chart index, output image format, and storage location
- Call the GetWorksheetChart() API to extract the specified chart from the worksheet and return it as an image stream in the desired format
- Write the image stream to a local file, saving the chart as a PNG image
These steps summarize the process of creating images for charts using Java REST Interfaces. The program authenticates with Aspose.Cells Cloud, uploads an Excel file and requests the export of a specific chart from a worksheet as a PNG image. It then saves the resulting image stream to a local file while handling any potential errors during the process.
Code to Convert Excel Graph to Image using Java Low Code API
This code demonstrates the process of generating chart image using Java RESTful Service. You can convert the chart to other formats such as TIFF, JPEG, GIF, EMF, and BMP. You may use the sheet name and 0-based index of the chart to render it as an image.
This article has taught us the process to render Excel charts. To create a bar chart in Excel, refer to the article Create Bar chart in Excel using Java REST API.