Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Poi XSSF-创建具有多个可扩展列的透视表_Java_Excel_Apache Poi_Xssf - Fatal编程技术网

Java Poi XSSF-创建具有多个可扩展列的透视表

Java Poi XSSF-创建具有多个可扩展列的透视表,java,excel,apache-poi,xssf,Java,Excel,Apache Poi,Xssf,我有大约1000行和多列,我想用它们创建一个透视表 我的实际结果是: 但我想得到一个透视表,如下所示: 我当前的代码: // ... // fill sheet with data // ... // create Pivot table int firstRow = sheet.getFirstRowNum() + firstDataRow; int lastRow = sheet.getLastRowNum(); int firstCol = sheet.getRow(0).get

我有大约1000行和多列,我想用它们创建一个透视表

我的实际结果是:

但我想得到一个透视表,如下所示:

我当前的代码:

// ... 
// fill sheet with data 
// ...

// create Pivot table
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);

XSSFPivotTable pivotTable = pivotSheet.createPivotTable(
        new AreaReference(topLeft, botRight), new CellReference(firstRow, lastCol), sheet);

pivotTable.addRowLabel(lastCol - 1); // month
pivotTable.addRowLabel(6); // car
pivotTable.addRowLabel(lastCol - 2); // state
pivotTable.addColumnLabel(DataConsolidateFunction.COUNT, 0, 
        resourceBundle.getString("Count"));
我甚至不知道如何命名不同的结果。 我认为我需要深入研究poi主题,以生成更复杂的透视表,但我不知道如何生成

有人能帮我解决这个问题吗?

找到了解决方案:

CTPivotFields pFields = pivotTable.getCTPivotTableDefinition().getPivotFields();
            pFields.getPivotFieldArray(lastCol - 1).setOutline(false);
            pFields.getPivotFieldArray(6).setOutline(false);
            pFields.getPivotFieldArray(lastCol - 2).setOutline(false);