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 MVC Framework Introduction Over the last few years, websites have shifted from simple HTML pages with a bit of CSS to incredibly complex applications with thousands of developers working on them at the same time. To work with these complex web applications developers use different design patterns to lay out their projects, to 6 min read Best Way to Master Spring Boot â A Complete Roadmap In the corporate world, they say "Java is immortal!". But Why? Java remains one of the major platforms for developing enterprise applications. Enterprise Applications are used by large companies to make money. Those applications have high-reliability requirements and an enormous codebase. According 14 min read Bash Scripting - If Statement Bash is an interpreter for command languages. It is a default command interpreter on most GNU/Linux systems and is widely available on various operating systems. The name is an abbreviation for Bourne-Again SHell. Scripting enables for the execution of instructions that would otherwise be executed o 15 min read MS Excel Tutorial - Learn Excel Online Free Excel, one of the most powerful spreadsheet programs for managing large datasets, performing calculations, and creating visualizations for data analysis. Developed and introduced by Microsoft in 1985, Excel is mostly used in analysis, data entry, accounting, and many more data-driven tasks.Now, if y 11 min read Spring Boot - Architecture Spring Boot is built on top of the core Spring framework. It simplifies and automates Spring-based application development by reducing the need for manual configuration. Spring Boot follows a layered architecture, where each layer interacts with other layers in a hierarchical order. The official Spr 3 min read How to Create a Shell Script in linux Shell is an interface of the operating system. It accepts commands from users and interprets them to the operating system. If you want to run a bunch of commands together, you can do so by creating a shell script. Shell scripts are very useful if you need to do a task routinely, like taking a backup 7 min read 200 Excel Interview Questions & Answers: Beginner to Expert (2025 Updated) Excel is an essential tool in many industries, and acing an Excel interview requires more than just basic knowledge. Whether you're applying for a data analyst, financial analyst, or administrative role, your ability to work efficiently with Excel can set you apart. In this article, we provide you w 15+ min read OSI Security Architecture The OSI Security Architecture is internationally recognized and provides a standardized technique for deploying security measures within an organization. It focuses on three major concepts: security attacks, security mechanisms, and security services, which are critical in protecting data and commun 8 min read Test Plan - Software Testing Software testing is important to make sure applications work properly and meet user needs. A clear and detailed test plan is the foundation of successful testing, guiding everything from creating test cases to fixing issues. In this article, we will break down what a test plan is, why itâs important 15+ min read X.509 Authentication Service X.509 is a digital certificate that is built on top of a widely trusted standard known as ITU or International Telecommunication Union X.509 standard, in which the format of PKI certificates is defined. X.509 digital certificate is a certificate-based authentication security framework that can be us 3 min read Like