Apache POI:Excel 枢轴 Table - 行标签
Apache POI : Excel Pivot Table - Row Label
我需要在 JAVA 中创建一个 excel sheet,如下所示:
我无法创建具有多个并排列的行标签(菜单和子菜单过滤器)。
不是在不同的列中显示子菜单,而是在菜单列的下面。
下面是我写的一段代码:
XSSFSheet sheet = my_xlsx_workbook.getSheetAt(0);
AreaReference a=new AreaReference("A1:G7");
CellReference b=new CellReference("I5");
XSSFPivotTable pivotTable = sheet.createPivotTable(a,b);
pivotTable.addReportFilter(0);
pivotTable.addReportFilter(1);
pivotTable.addRowLabel(2);
pivotTable.addRowLabel(3);
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 4, "Sum");
但是显示错误如下:
有人可以帮我吗?
由于格式是 XML,所以很容易检查需要什么。解压 Zip
xlsx 并查看 /xl/pivotTables/pivotTable1.xml
.
然后:https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFPivotTable.html#getCTPivotTableDefinition%28%29 and http://grepcode.com/file/repo1.maven.org/maven2/org.apache.poi/ooxml-schemas/1.1/org/openxmlformats/schemas/spreadsheetml/x2006/main/CTPivotTableDefinition.java.
AreaReference a=new AreaReference(new CellReference("A1"), new CellReference("E7"));
CellReference b=new CellReference("I5");
XSSFPivotTable pivotTable = sheet.createPivotTable(a,b);
pivotTable.addReportFilter(0);
pivotTable.addReportFilter(1);
pivotTable.addRowLabel(2);
pivotTable.getCTPivotTableDefinition().getPivotFields().getPivotFieldArray(2).setOutline(false);
pivotTable.addRowLabel(3);
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 4, "Sum");
我需要在 JAVA 中创建一个 excel sheet,如下所示:
我无法创建具有多个并排列的行标签(菜单和子菜单过滤器)。
不是在不同的列中显示子菜单,而是在菜单列的下面。
下面是我写的一段代码:
XSSFSheet sheet = my_xlsx_workbook.getSheetAt(0);
AreaReference a=new AreaReference("A1:G7");
CellReference b=new CellReference("I5");
XSSFPivotTable pivotTable = sheet.createPivotTable(a,b);
pivotTable.addReportFilter(0);
pivotTable.addReportFilter(1);
pivotTable.addRowLabel(2);
pivotTable.addRowLabel(3);
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 4, "Sum");
但是显示错误如下:
有人可以帮我吗?
由于格式是 XML,所以很容易检查需要什么。解压 Zip
xlsx 并查看 /xl/pivotTables/pivotTable1.xml
.
然后:https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFPivotTable.html#getCTPivotTableDefinition%28%29 and http://grepcode.com/file/repo1.maven.org/maven2/org.apache.poi/ooxml-schemas/1.1/org/openxmlformats/schemas/spreadsheetml/x2006/main/CTPivotTableDefinition.java.
AreaReference a=new AreaReference(new CellReference("A1"), new CellReference("E7"));
CellReference b=new CellReference("I5");
XSSFPivotTable pivotTable = sheet.createPivotTable(a,b);
pivotTable.addReportFilter(0);
pivotTable.addReportFilter(1);
pivotTable.addRowLabel(2);
pivotTable.getCTPivotTableDefinition().getPivotFields().getPivotFieldArray(2).setOutline(false);
pivotTable.addRowLabel(3);
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 4, "Sum");