java中怎么利用poi导出excel透视表

  介绍

这期内容当中小编将会给大家带来有关java中怎么利用poi导出excel透视表,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

代码如下:

//,利用esaypoi生成excel数据,即sheet1里面的数据   Workbook  Workbook =, ExcelExportUtil.exportExcel (new  ExportParams (null,,“sheet1",, ExcelType.XSSF),, pojoClass,,列表);   ,,,Sheet  sheet1 =, workbook.getSheetAt (0);   ,,,sheet1.setDefaultColumnWidth (50, *, 256);   ,,,sheet1.setDefaultRowHeight((短)(2,*,256));      ,,,//,创建数据透视表   ,,,XSSFSheet  pivotSheet =, (XSSFSheet ) workbook.createSheet ();   ,,,pivotSheet.setDefaultColumnWidth (50, *, 256);      ,,,//,获取数据表的总行数   ,,,int  num =, sheet1.getLastRowNum ();   ,,,//,数据透视表数据源的起点单元格位置   ,,,CellReference  topLeft =, new  CellReference (“A1");   ,,,//,数据透视表数据源的终点单元格位置   ,,,CellReference  botRight =, new  CellReference ((“M" + num));   ,,,//,数据透视表生产的起点单元格位置   ,,,CellReference  ptStartCell =, new  CellReference (“A1");   ,,,AreaReference  areaR =, new  AreaReference (botRight topLeft也);   ,,,XSSFPivotTable  pivotTable =, pivotSheet.createPivotTable (ptStartCell,占地,还以为;sheet1);   ,,,//,添加行标签   ,,,pivotTable.addRowLabel(4),,//,部门   ,,,pivotTable.addRowLabel(1),,//,科目   ,,,pivotTable.addRowLabel(0);,//,借贷方向   ,,,pivotTable.addRowLabel(11);,//,单据编的号   ,,,pivotTable.addRowLabel(12);,//,凭证编的号   ,,,pivotTable.addRowLabel(9),,//,付款编码   ,,,pivotTable.addRowLabel(10),,//,付款时间   ,,,pivotTable.addColumnLabel (DataConsolidateFunction.SUM,, 3,,“分录金额“);   ,,,//,将透视表的列以表格的样式显示,这个地方弄了好久   ,,,int  count =, 13,,//,计数为数据源的列的数量   ,,,for  (int 小姐:=,0;,小姐:& lt;,计数;,我+ +),{   ,,,,,CTPivotField  CTPivotField =, pivotTable.getCTPivotTableDefinition () .getPivotFields () .getPivotFieldArray(我);   ,,,,,ctPivotField.setOutline(假);   ,,,}

上述就是小编为大家分享的java中怎么利用poi导出excel透视表了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注行业资讯频道。

java中怎么利用poi导出excel透视表