Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.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 Apache POI XSSF-如何添加;“两级”;数据透视表中的列标签数目_Java_Excel_Apache Poi - Fatal编程技术网

Java Apache POI XSSF-如何添加;“两级”;数据透视表中的列标签数目

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

我使用文件Test.xlsx中的ApachePOI3.14生成了PIVOT表
注意: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方法的链接