我想生成一个数据透视表,所有列都应该有如图所示的过滤器。
无论如何都要在poi中为每个col激活它,除了最后一个col,因为它只是一个总和col?
用于生成数据透视表的Ma当前代码:
int firstRow = sheet.getFirstRowNum() + firstDataRow;
int lastRow = sheet.getLastRowNum();
int firstCol = sheet.getRow(0).getFirstCellNum();
int lastCol = sheet.getRow(firstRow).getLastCellNum();
CellReference topLeft = new CellReference(firstRow, firstCol);
CellReference botRight = new CellReference(lastRow, lastCol - 1);
AreaReference areaRef = new AreaReference(topLeft, botRight);
XSSFPivotTable pivotTable = pivotSheet.createPivotTable(areaRef,
new CellReference(firstRow, firstCol), sheet);
pivotTable.addRowLabel(lastCol - 1); // Month
pivotTable.addRowLabel(6); // User
pivotTable.addRowLabel(lastCol - 2); // State
pivotTable.addColumnLabel(DataConsolidateFunction.COUNT, 0,
resBundle.getString("WG_NM")); // count
CTPivotFields pFields =
pivotTable.getCTPivotTableDefinition().getPivotFields();
pFields.getPivotFieldArray(lastCol - 1).setOutline(false);
pFields.getPivotFieldArray(6).setOutline(false);
pFields.getPivotFieldArray(lastCol - 2).setOutline(false);