javaexceljxljexcelapi

Keeping Pivot Table and Formating intact in JExcel


I am trying to write data to an excel sheet using JExcel. I have an excel file placed on disk and I opened it using JExcel and then created a Writable Workbook. The Excel workbook contains sheets having pivot table. Idea is to just populate source sheets and then refresh the pivot tables. But after creating Writable Workbook, the formatting and pivot tables got away.

Here is my code snippet:

 FileInputStream fileInputStream = new FileInputStream("C:\\Pivot_File_template.xls");
 workbook = Workbook.getWorkbook(fileInputStream);          
 WorkbookSettings workbookSettings = new WorkbookSettings();            
 writableWorkbook = Workbook.createWorkbook(new File("C:\\Writable_Pivot_File.xls"),workbook,workbookSettings);

The file "Writable_Pivot_File.xls" just lost the orignal formatting and pivot tables. Any suggestions what I can do to maintain all the formatting and pivot tables? I am using "jxl_2.6.9.jar". Thanks in advance.


Solution

  • Just got away with this issue by using Apache POI. JExcel doesnot support xlsx and updating an xls file having pivot table using JExcel will disable the Pivot table and change its formatting.