简体   繁体   English

使用Apache POI 3.9克隆数据透视表?

[英]Clone pivot table with Apache POI 3.9?

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? 有没有人知道如何使用Apache POI从现有的excel文件中读取数据透视表,然后将其添加到新文件中?

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? 关于我还能尝试什么的任何想法?

According to the limitations on the POI site, you can't create a new pivot table. 根据POI站点的限制 ,您无法创建新的数据透视表。

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. 打开该数据透视表,清除除第一行(第0行,因为它们从0开始)之外的所有行,然后将数据写入适当的列和行。 Finally write out the spreadsheet as a new file and there you go, you've got a clone of your pivot table. 最后将电子表格写成一个新文件,然后你就可以了解你的数据透视表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM