Java Apache POI XSSF-如何添加;“两级”;数据透视表中的列标签数目
我使用文件Test.xlsx中的ApachePOI3.14生成了PIVOT表Java Apache POI XSSF-如何添加;“两级”;数据透视表中的列标签数目,java,excel,apache-poi,Java,Excel,Apache Poi,我使用文件Test.xlsx中的ApachePOI3.14生成了PIVOT表 注意:addColLabel方法来自JensGabe的链接。根据链接,此方法(XSSFPivotTable.addRowLabel的稍微修改版本)添加了一个“普通”透视列标签。 public static void main(String[] args){ Connection conn = null; try { //Input file XSSFWorkbook wb = new
注意:addColLabel方法来自JensGabe的链接。根据链接,此方法(XSSFPivotTable.addRowLabel的稍微修改版本)添加了一个“普通”透视列标签。
public static void main(String[] args){
Connection conn = null;
try
{
//Input file
XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream("Excel_pivot_template_2.xlsx"));
XSSFSheet sheet = wb.getSheetAt(0);
XSSFPivotTable pivotTable = sheet.createPivotTable(new AreaReference(new CellReference("A3"), new CellReference("E11")), new CellReference("I3"));
//second column from the input file
pivotTable.addRowLabel(1);
addColLabel(pivotTable, 0);
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 2);
FileOutputStream fileOut = new FileOutputStream("pivot_output.xlsx");
wb.write(fileOut);
fileOut.close();
wb.close();
System.out.println("********* Complete *********** ");
}
程序的输入和输出: 预期产出:
非常感谢您的帮助。我还没有取得任何成功。这是实现addColLabel方法的链接这是实现addColLabel方法的链接