Excel中的“显示详细信息/隐藏详细信息”选项用于折叠数据透视表字段

我创build了一个实用程序来创build数据透视表,但无法将其折叠。 这是我的代码:

/* Read the input file that contains the data to pivot */ FileInputStream input_document = new FileInputStream(new File("D:\\StateCity.xlsx")); /* Create a POI XSSFWorkbook Object from the input file */ XSSFWorkbook my_xlsx_workbook = new XSSFWorkbook(input_document); /* Read Data to be Pivoted - we have only one worksheet */ XSSFSheet sheet = my_xlsx_workbook.getSheetAt(1); /* Get the reference for Pivot Data */ AreaReference a=new AreaReference("A1:D11"); /* Find out where the Pivot Table needs to be placed */ CellReference b=new CellReference("A2"); XSSFSheet license_usage = my_xlsx_workbook.getSheet("sheet2"); XSSFSheet sheet1 = (XSSFSheet) my_xlsx_workbook.createSheet("license_pivot_table"); /* Create Pivot Table */ XSSFPivotTable pivotTable = sheet1.createPivotTable(a,b,license_usage); pivotTable.addRowLabel(0); pivotTable.addRowLabel(1); pivotTable.addRowLabel(2); pivotTable.addRowLabel(3); for(CTPivotField ctPivotField:pivotTable.getCTPivotTableDefinition().getPivotFields().getPivotFieldList()){ ctPivotField.setAutoShow(false); ctPivotField.setOutline(false); ctPivotField.setCompact(false); ctPivotField.setSubtotalTop(false); ctPivotField.setSubtotalCaption(""); } pivotTable.getCTPivotTableDefinition().setRowGrandTotals(false); CTPivotTableDefinition ctPivotTableDefinition = pivotTable.getCTPivotTableDefinition(); CTPivotTableStyle ctPivotTableStyle = ctPivotTableDefinition.getPivotTableStyleInfo(); ctPivotTableStyle.setName("PivotStyleMedium3"); /* Write Pivot Table to File */ FileOutputStream output_file = new FileOutputStream(new File("D:\\POI_XLS_Pivot_ExampleTest.xlsx")); my_xlsx_workbook.write(output_file); input_document.close(); 

我不想使用Aspose.Cells,因为它是许可产品。