Reputation: 2647
Does anyone have any idea how to use Apache POI to read a pivot table from an existing excel file and then add it to a new file?
I already tried to clone an existing sheet, but unfortunately only the values were copied, hence it cannot be done this way...
Any ideas on what else I can try?
Upvotes: 1
Views: 2168
Reputation: 1538
According to the limitations on the POI site, you can't create a new pivot table.
That being said, what I'd recommend (and the system that I work on does) is to use a template pivot table. Open that pivot table, clear out all rows except for the first row (row #0, as they are 0-based), then write your data into the appropriate columns and rows. Finally write out the spreadsheet as a new file and there you go, you've got a clone of your pivot table.
Upvotes: 3