How to Create Pivot Chart from Pivot Table in Excel using Java? Last Updated : 06 Dec, 2023 Comments Improve Suggest changes Like Article Like Report A Pivot Chart is used to analyze data of a table with very little effort (and no formulas) and it gives you the big picture of your raw data. It allows you to analyze data using various types of graphs and layouts. It is considered to be the best chart during a business presentation that involves huge data. To add a pivot chart to an Excel worksheet, you need to use the "WorksheetChartsCollection.add" method. Before Creating a Pivot Chart, one first needs to go through how to Create Pivot Table in Excel using Java. Now let's discuss the steps to create a pivot chart in an Excel file in Java using Free Spire.XLS for Java API. How to Create a Pivot Table in Excel using JavaStep 1: Load the Excel fileWorkbook workbook = new Workbook() String workbookName = "Geeks_For_Geeks.xlsx"; workbook.loadFromFile(workbookName); Step 2: Get the first worksheetWorksheet sheet = workbook.getWorksheets().get(0); Step 3: Get the first pivot table in the worksheetIPivotTable pivotTable = sheet.getPivotTables().get(0); Step 4: Add a clustered column chart based on the pivot table to the second worksheetChart chart = workbook.getWorksheets().get(1).getCharts().add(ExcelChartType.ColumnClustered, pivotTable); Step 5: Set chart positionchart.setTopRow(2); chart.setBottomRow(15); Step 6: Set chart titlechart.setChartTitle("Total"); Step 7: Save the result fileworkbook.saveToFile(workbookName, ExcelVersion.Version2013); Let's write a Java Program to create a pivot chart from a pivot table in a spreadsheet. Java import com.spire.xls.*; import com.spire.xls.core.IPivotTable; class GFG { public static void main(String[] args) { // Load the Excel file Workbook workbook = new Workbook(); String workbookName = "Geeks_For_Geeks.xlsx"; workbook.loadFromFile(workbookName); // Get the first worksheet Worksheet sheet = workbook.getWorksheets().get(0); // get the first pivot table in the worksheet IPivotTable pivotTable = sheet.getPivotTables().get(0); // Add a clustered column chart based on the pivot // table to the second worksheet Chart chart = workbook.getWorksheets() .get(1) .getCharts() .add(ExcelChartType.ColumnClustered, pivotTable); // Set chart position chart.setTopRow(2); chart.setBottomRow(15); // Set chart title chart.setChartTitle("Total"); // Save the result file workbook.saveToFile(workbookName, ExcelVersion.Version2013); System.out.println(workbookName + " is written successfully"); } } OutputOn the console window when the program is successfully executed. GeeksForGeeks.xlsx is written successfully. OutputOn the Workbook (Excel file) Conclusion Creating a Pivot chart from a pivot table in Excel using Java can greatly improve data analysis and visualization. By programmatically generating pivot tables and charts with Apache POI, you can automate repetitive tasks and efficiently handle large datasets. This article provides you step by step implementation of how to create a pivot chart in Excel using Java. Comment More infoAdvertise with us Next Article How to Create Pivot Chart from Pivot Table in Excel using Java? N nandinigujral Follow Improve Article Tags : Excel Geeks-Premier-League-2022 Excel-functions excel Similar Reads How to Create Pivot Table in Excel using Java? A pivot table is needed to quickly analyze data of a table with very little effort (and no formulas) and sometimes not everyone has time to look at the data in the table and see whatâs going on and use it to build good-looking reports for large data sets in an Excel worksheet. Let's discuss a step-b 5 min read How to Create a Formula in Excel using Java? Apache POI is a popular open-source Java library that provides programmers with APIs for creating, modifying, and editing MS Office files. Excel is very excellent at calculating formulas. And perhaps most Excel documents have formulas embedded. Therefore, itâs trivial that on a fine day, you have to 3 min read How to Group and Ungroup Pivot Chart Data Items in Excel? A pivot chart is the visual representation of a pivot table in Excel. Pivot charts and pivot tables are connected with each other. Pivot chart are much more flexible than normal chart because Pivot Chart is linked to a PivotTable. Filters, sorts, and data rearrangements applied to Pivot Table are re 2 min read How to Create a Power PivotTable in Excel? When we have to compare the data (such as name/product/items, etc.) between any of the columns in excel then we can easily do with the help of Pivot table and pivot charts. But it fails when it comes to comparing those data which are in two different datasets, at that time Power Pivot comes into rol 4 min read How to Prevent Grouped Dates In Excel Pivot Table? We may group dates, numbers, and text fields in a pivot table. Organize dates, for instance, by year and month. In a pivot table field, text elements can be manually selected. The selected things can then be grouped. This enables you to rapidly view the subtotals in your pivot table for a certain gr 3 min read How to Create a Chart from Multiple Sheets in Excel Creating a chart from multiple sheets in Excel is a powerful way to consolidate data and visualize it in a meaningful way. Whether you're working with different datasets on separate sheets or need to compare data across multiple tabs, knowing how to create a chart from multiple sheets in Excel can s 5 min read How to Sort a Pivot Table in Excel : A Complete Guide Sorting a Pivot Table in Excel is a powerful way to organize and analyze data effectively. Whether you want to sort alphabetically, numerically, or apply a custom sort in Excel, mastering this feature allows you to extract meaningful insights quickly. This guide walks you through various Pivot Table 7 min read How To Create Interactive Charts in Excel? In MS Excel, we can draw various charts, but among them today, we will see the interactive chart. By name, we can analyze that the chart, which is made up of interactive features, is known as an interactive chart. In general, this chart makes the representation in a better and more user-friendly way 9 min read How to Create a Timeline or Milestone Chart in Excel? A timeline is a type of chart that visually shows a series of events in chronological order over a linear timescale. The power of a timeline is that it is graphical, which makes it easy to understand critical milestones, such as the progress of a project schedule. Benefits of using Timeline / Milest 2 min read How to Create Dynamic Chart Titles In Excel? Excel is a tool that is generally used by accounting professionals for financial data analysis but can be used for different purposes. It can be used for data visualization, data analysis, and data management, which uses spreadsheets for managing, storing, and visualizing large volumes of data. Cell 2 min read Like