简体   繁体   English

如何使用 apache poi 创建带有 xssf 的 pivot 表?

[英]How to create a pivot table with xssf using apache poi?

I have a requirement where i need the pivot table in following manner:我有一个要求,我需要按以下方式使用 pivot 表:

在此处输入图像描述

I needed the output in the above manner, but I'm getting in the following manner:我以上述方式需要 output,但我以以下方式获得:

在此处输入图像描述

I have written the code in following manner:我以以下方式编写了代码:

pivotTable.addReportFilter( 12 );
pivotTable.addReportFilter( 13 );
pivotTable.addRowLabel( 11 );
pivotTable.addDataColumn( 15, true );
pivotTable.addColumnLabel( DataConsolidateFunction.SUM, 15 );

How to get the column filter as required??如何根据需要获取列过滤器?

I have updated the apache-poi from 3.14 to 4.1.0, where 4.1.x version provides the method addColLabel(columnIndex).我已将 apache-poi 从 3.14 更新到 4.1.0,其中 4.1.x 版本提供方法 addColLabel(columnIndex)。 Using addColLabel(columnIndex) allows to select particular column as column fields for the pivot table creation.使用 addColLabel(columnIndex) 允许将 select 特定列作为 pivot 表创建的列字段。

Code:代码:

            pivotTable.addReportFilter( 12 );
            pivotTable.addReportFilter( 13 );
            pivotTable.addRowLabel( 11 );
            pivotTable.addColLabel( 0 );
            pivotTable.addColumnLabel( DataConsolidateFunction.SUM, 15 );

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

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