【问题标题】:Count column in Pivot Table with same column index计算数据透视表中具有相同列索引的列
【发布时间】:2016-08-02 20:41:46
【问题描述】:

我在网上搜索了很多,但无法找到错误的解决方案。

代码

        AreaReference areaRef = new AreaReference("A1:T"+ sheet.getLastRowNum());
        CellReference cellRef = new CellReference("A2");
        XSSFPivotTable pivotTable = summarysheet.createPivotTable(areaRef,cellRef,sheet);
        pivotTable.addRowLabel(19);
        pivotTable.addColumnLabel(DataConsolidateFunction.COUNT, 19);

问题:我正在尝试在索引 19 上添加 RowLabel,并尝试计算第 19 列。

运行后,显示文件已损坏的错误。但是当我更改 addColumnLabel 中的索引时。有用。

任何建议或建议将不胜感激。

【问题讨论】:

    标签: java apache-poi pivot-table


    【解决方案1】:

    所以这里的问题是,当您将行标签设置为 19 列时,它不会将其设置为数据字段,并且当您对同一列进行计数时它会失败,快速解决方法是将该特定列设置为不既要作为axisRow,又要作为数据字段由

    pivotTable.addColumnLabel(DataConsolidateFunction.COUNT, 19);
    pivotTable.addRowLabel(19);
    pivotTable.getCTPivotTableDefinition().getPivotFields().getPivotFieldArray(19).setDataField(true);
    

    试试看!!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-28
      • 1970-01-01
      • 2020-10-19
      • 2020-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多