Datouguai_sws
2019-12-13 21:38 阅读 437

java poi导出excel文档 后台报下标越界 但文档正常导出且损坏

public static SXSSFWorkbook createCSVUtil2(int startRow, String sheetName, SXSSFWorkbook wb,
Map> cellListMap, Integer cellRowNum, List exportData,
int[] columnWidth, int totalcolumn, GgreportingtemplateDto ggreportingtemplateDto, int countRow)
throws Exception {
// 设置表格名称
SXSSFSheet sheet = (SXSSFSheet) wb.createSheet(sheetName);
sheet.trackAllColumnsForAutoSizing();
// 设置表格标题 一般都是第一行第一个格子
// 标题样式
if (ggreportingtemplateDto.getTitle() != null) {
XSSFCellStyle cellStyleTitle = (XSSFCellStyle) wb.createCellStyle();
cellStyleTitle.setWrapText(true);
SXSSFRow rowTitle = (SXSSFRow) sheet.createRow(0);
XSSFFont fontTitle = (XSSFFont) wb.createFont();
fontTitle.setFontHeightInPoints((short) 16);
cellStyleTitle.setFont(fontTitle);
// 合并标题单元格
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, totalcolumn - 1));
for (int i = 0; i < totalcolumn; i++) {
if (i == 0) {
SXSSFCell cell = (SXSSFCell) rowTitle.createCell(0);
cell.setCellValue(ggreportingtemplateDto.getTitle());
cell.setCellStyle(cellStyleTitle);
} else {
SXSSFCell cell = (SXSSFCell) rowTitle.createCell(i);
cell.setCellStyle(cellStyleTitle);
}
}
}

    if (ggreportingtemplateDto.getCondition() != null) {
        // 设置筛选条件格子 一般是第二行第一列
        // 条件样式
        XSSFCellStyle cellStyleCondition = (XSSFCellStyle) wb.createCellStyle();
        cellStyleCondition.setWrapText(true);
        SXSSFRow rowCondition = (SXSSFRow) sheet.createRow(1);
        XSSFFont fontCondition = (XSSFFont) wb.createFont();
        fontCondition.setFontHeightInPoints((short) 16);
        cellStyleCondition.setFont(fontCondition);
        // 合并条件单元格
        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 4));
        for (int i = 0; i < 4; i++) {
            if (i == 0) {
                SXSSFCell cell = (SXSSFCell) rowCondition.createCell(0);
                cell.setCellValue(ggreportingtemplateDto.getCondition());
                cell.setCellStyle(cellStyleCondition);
            } else {
                SXSSFCell cell = (SXSSFCell) rowCondition.createCell(i);
                cell.setCellStyle(cellStyleCondition);
            }
        }
    }

    // 设置表格通用样式
    XSSFCellStyle cellStyle = (XSSFCellStyle) wb.createCellStyle();
    // 设置边框
    // 设置单元格内容水平对齐
    cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
    // 设置单元格内容垂直对齐
    cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
    // 设置自动换行
    cellStyle.setWrapText(true);
    // 设置双边框
    XSSFCellStyle cellStyleDouble = (XSSFCellStyle) wb.createCellStyle();
    // 设置边框
    // 设置单元格内容水平对齐
    cellStyleDouble.setAlignment(XSSFCellStyle.ALIGN_CENTER);
    // 设置单元格内容垂直对齐
    cellStyleDouble.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
    // 设置自动换行
    cellStyleDouble.setWrapText(true);
    // 合并单元格
    for (int t = 0; t < cellRowNum; t++) {
        SXSSFRow row = (SXSSFRow) sheet.createRow(t + startRow);
        List<CellModel> cellNameList = cellListMap.get(String.valueOf(t));
        for (CellModel cellModel : cellNameList) {
            // 如果被合并的元素只占用了一个单元格则不进行合并
            if (cellModel.getStartColumn() == cellModel.getEndColumn()
                    && cellModel.getEndRow() == cellModel.getStartRow()) {
                continue;
            }
            sheet.addMergedRegion(new CellRangeAddress(cellModel.getStartRow(), cellModel.getEndRow(),
                    cellModel.getStartColumn(), cellModel.getEndColumn()));
        }
        // create的cell
        Set<Integer> create = new HashSet<Integer>();
        for (int i = 0; i < cellNameList.size(); i++) {
            CellModel cellModel = cellNameList.get(i);
            // 遍历插入表头
            SXSSFCell cell = (SXSSFCell) row.createCell(cellModel.getStartColumn());
            // 设置字体
            XSSFFont font = (XSSFFont) wb.createFont();
            font.setFontName("Times New Roman");
            font.setFontHeightInPoints((short) 8);
            // 设置行高
            if (i == 1) {
                row.setHeight((short) 500);
            }
            cellStyle.setFont(font);
            cell.setCellValue(cellModel.getCellName());
            cell.setCellStyle(cellStyle);
            create.add(cellModel.getStartColumn());
        }
        // 把所有没有create的cell都create
        for (int i = 0; i < totalcolumn; i++) {
            if (!(create.contains(i))) {
                // 设置字体
                XSSFFont font = (XSSFFont) wb.createFont();
                font.setFontName("Times New Roman");
                font.setFontHeightInPoints((short) 8);
                cellStyle.setFont(font);
                SXSSFCell cell = (SXSSFCell) row.createCell(i);
                cell.setCellStyle(cellStyle);
            }
        }
    }
    for (LinkedHashMap hashMap : exportData) {
        SXSSFRow rowValue = (SXSSFRow) sheet.createRow(cellRowNum + startRow);
        Iterator<Map.Entry> iteratorRow = hashMap.entrySet().iterator();
        while (iteratorRow.hasNext()) {
            Map.Entry entryRow = iteratorRow.next();
            Integer key = Integer.valueOf(entryRow.getKey().toString());
            String value = "";
            if (entryRow.getValue() != null) {
                value = entryRow.getValue().toString();
            } else {
                value = "";
            }
            SXSSFCell cellValue = (SXSSFCell) rowValue.createCell(key - 1);
            // 设置字体
            XSSFFont font = (XSSFFont) wb.createFont();
            font.setFontName("Times New Roman");
            font.setFontHeightInPoints((short) 8);
            cellValue.setCellValue(value);
            cellStyle.setFont(font);
            cellValue.setCellStyle(cellStyle);
        }
        cellRowNum++;
    }
    // 设置备注栏
    List<String> reMarkList = ggreportingtemplateDto.getRemake();
    if (reMarkList != null) {
        for (int i = 0; i < reMarkList.size() + 1; i++) {
            int rowNum = i + startRow + cellRowNum + 1;
            XSSFCellStyle cellStyleRemake = (XSSFCellStyle) wb.createCellStyle();
            SXSSFRow rowRemake = (SXSSFRow) sheet.createRow(rowNum);
            XSSFFont fontRemake = (XSSFFont) wb.createFont();
            fontRemake.setFontHeightInPoints((short) 8);
            cellStyleRemake.setFont(fontRemake);
            String cellValue = "Notes:";
            // 合并条件单元格
            if (i != 0) {
                sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 4));
                cellValue = reMarkList.get(i - 1);
                SXSSFCell cell = (SXSSFCell) rowRemake.createCell(0);
                cell.setCellValue(cellValue);
                cell.setCellStyle(cellStyleRemake);
            } else {
                SXSSFCell cell = (SXSSFCell) rowRemake.createCell(0);
                cell.setCellValue(cellValue);
                cell.setCellStyle(cellStyleRemake);
            }
        }
    }
    // 设置列宽
    if (columnWidth != null) {
        for (int i = 0; i < columnWidth.length; i++) {
            sheet.setColumnWidth(i, columnWidth[i]);
        }
    }
    return wb;
}
以上是我生成sheet表的内容

//exceptional Rpt
public SXSSFWorkbook exceptionalRpt (GgreportingtemplateDto ggreportingtemplateDto, String startInputDate,String endInputDate) throws Exception {
    // 设置最大数据行数
    SXSSFWorkbook wb = new SXSSFWorkbook(5050);//这里之前看到是说能设置这个表格最多能含有多少数据
    Map<String, List<CellModel>> map = new HashMap<String, List<CellModel>>();
    // 设置数据
    // 第一级表头
    List<CellModel> firstRow = new ArrayList<CellModel>();
    CellModel cellModel1 = new CellModel();
    // 总占用1行
    Integer cellRow = 1;
    cellModel1.setCellName("Member English Name");
    cellModel1.setStartRow(0);
    cellModel1.setEndRow(0);
    cellModel1.setStartColumn(0);
    cellModel1.setEndColumn(0);

    CellModel cellModel2 = new CellModel();
    cellModel2.setCellName("Member Chinese Name");
    cellModel2.setStartRow(0);
    cellModel2.setEndRow(0);
    cellModel2.setStartColumn(1);
    cellModel2.setEndColumn(1);

    CellModel cellModel3 = new CellModel();
    cellModel3.setCellName("Staff No.");
    cellModel3.setStartRow(0);
    cellModel3.setEndRow(0);
    cellModel3.setStartColumn(2);
    cellModel3.setEndColumn(2);

    CellModel cellModel4 = new CellModel();
    cellModel4.setCellName("HKID/Passport No.");
    cellModel4.setStartRow(0);
    cellModel4.setEndRow(0);
    cellModel4.setStartColumn(3);
    cellModel4.setEndColumn(3);

    CellModel cellModel5 = new CellModel();
    cellModel5.setCellName("Sex");
    cellModel5.setStartRow(0);
    cellModel5.setEndRow(0);
    cellModel5.setStartColumn(4);
    cellModel5.setEndColumn(4);

    CellModel cellModel6 = new CellModel();
    cellModel6.setCellName("Plan Code");
    cellModel6.setStartRow(0);
    cellModel6.setEndRow(0);
    cellModel6.setStartColumn(5);
    cellModel6.setEndColumn(5);

    CellModel cellModel7 = new CellModel();
    cellModel7.setCellName("Plan Description");
    cellModel7.setStartRow(0);
    cellModel7.setEndRow(0);
    cellModel7.setStartColumn(6);
    cellModel7.setEndColumn(6);

    CellModel cellModel8 = new CellModel();
    cellModel8.setCellName("Effective Date");
    cellModel8.setStartRow(0);
    cellModel8.setEndRow(0);
    cellModel8.setStartColumn(7);
    cellModel8.setEndColumn(7);

    CellModel cellModel9 = new CellModel();
    cellModel9.setCellName("Status");
    cellModel9.setStartRow(0);
    cellModel9.setEndRow(0);
    cellModel9.setStartColumn(8);
    cellModel9.setEndColumn(8);

    firstRow.add(cellModel1);
    firstRow.add(cellModel2);
    firstRow.add(cellModel3);
    firstRow.add(cellModel4);
    firstRow.add(cellModel5);
    firstRow.add(cellModel6);
    firstRow.add(cellModel7);
    firstRow.add(cellModel8);
    firstRow.add(cellModel9);
    map.put("0", firstRow);
    // 业务数据
    List<LinkedHashMap> exportData = new ArrayList<LinkedHashMap>();
    GuPolicyCopyItemMedgMembDto guPolicyCopyItemMedgMembDto = new GuPolicyCopyItemMedgMembDto();
    List<GuPolicyCopyItemMedgMembDto> list = ServiceManager.prpall.getGuPolicyCopyItemMedgMembService().findALL(guPolicyCopyItemMedgMembDto, null);//这里查询出来是295条
    //增加数据 用这端代码增加5000条数据
    /*for (int i = 0; i < 5000; i++) {
        list.add((GuPolicyCopyItemMedgMembDto)list.get(0));
    }*/
    int countRow = 0;
    for (int i = 0; i < list.size(); i++) {
        GuPolicyCopyItemMedgMembDto data = (GuPolicyCopyItemMedgMembDto) list.get(i);
        LinkedHashMap<String,String> row = new LinkedHashMap<String,String>();
        String struts = "";
        String ename = "";
        String cname = "";
        String idno = "";
        String staffno = "";
        String sex = "";
        String rationType = "";
        String rationName = "";
        String entryDate  = "";
        String chineseName = "";
        String hKIDandPassportNo = "";
        if(data.getFlag()==null||data.getFlag().equals("I")) {
            struts = "Add";
        }else if(data.getFlag().equals("U")){
            struts = "Amendment";
        }else if(data.getFlag().equals("D")){
            struts = "Deletion";
        }else if(data.getFlag().equals("B")){
            struts = "Cancellation";
        }
        if(data.getClientEName() != null&&!(data.getClientEName().equals(""))) {
            ename = data.getClientEName();
        }
        if(data.getClientCName() != null&&!(data.getClientCName().equals(""))) {
            cname = data.getClientCName();
        }
        if(data.getIdNo() != null&&!(data.getIdNo().equals(""))) {
            idno = data.getIdNo();
        }
        if(data.getStaffNo() != null&&!(data.getStaffNo().equals(""))) {
            staffno = data.getStaffNo();
        }
        if(data.getSex() != null&&!(data.getSex().equals(""))) {
            sex = data.getSex();
        }
        if(data.getRationType() != null&&!(data.getRationType().equals(""))) {
            rationType = data.getRationType();
        }
        if(data.getRationName() != null&&!(data.getRationName().equals(""))) {
            rationName = data.getRationName();
        }
        if(data.getEntryDate() != null) {
            entryDate = sim.format(data.getEntryDate());
        }
        /*row.put("1", ""+ename+"");
        row.put("2", ""+cname+"");
        row.put("3", ""+staffno+"");
        row.put("4", ""+idno+"");
        row.put("5", ""+sex+"");
        row.put("6", ""+rationType+"");
        row.put("7", ""+rationName+"");
        row.put("8", ""+entryDate+"");
        row.put("9", ""+struts+"");*/
        row.put("1", "1");
        row.put("2", "2");
        row.put("3", "3");
        row.put("4", "4");
        row.put("5", "5");
        row.put("6", "6");
        row.put("7", "7");
        row.put("8", "8");
        row.put("9", "9");
        exportData.add(row);
        countRow++;
    }
    // 用于写入文件
    // 列宽数组
    int[] columnWidth = { 10000, 7500, 5000, 7500, 5000, 7500, 10000, 5000, 5000 };
    // 报表标题
    ggreportingtemplateDto.setTitle(null);
    List<String> remakeList = null;
    // 报表备注
    ggreportingtemplateDto.setRemake(remakeList);
    ggreportingtemplateDto.setCondition(null);
    //数据分页
    if(exportData.size()>5000) {
        double size = exportData.size();
        double divisor = size/5000;
        int forNumber = (new Double(Math.ceil(divisor))).intValue();
        for (int i = 0; i < forNumber; i++) {
            if((i+1)==forNumber) {
                List<LinkedHashMap> exportDataTemp = exportData.subList(0+(i*5000), exportData.size()-1);
                wb = this.createCSVUtil2(0, "Exceptional Rpt"+(i+1), wb, map, cellRow, exportDataTemp, columnWidth, columnWidth.length,
                        ggreportingtemplateDto, 0);
            }else {
                List<LinkedHashMap> exportDataTemp = exportData.subList(0+(i*5000), 5000+(i*5000 ));
                wb = this.createCSVUtil2(0, "Exceptional Rpt"+(i+1), wb, map, cellRow, exportDataTemp, columnWidth, columnWidth.length,
                        ggreportingtemplateDto, 0);
            }
        }
    }else {
        wb = this.createCSVUtil2(0, "Exceptional Rpt", wb, map, cellRow, exportData, columnWidth, columnWidth.length,
                ggreportingtemplateDto, 0);
    }
    /*wb = this.createCSVUtil2(0, "Exceptional Rpt", wb, map, cellRow, exportData, columnWidth, columnWidth.length,
            ggreportingtemplateDto, 0);*/
    return wb;
}




一开始SXSSFWorkbook wb = new SXSSFWorkbook(5050)这里的值给的5000 ,然后当数据量大于5000时直接报错,文件不能正常导出,然后我把5000改成7000,会报错但是文件能导出,是损坏文件,一条数据都没有,后来修改成分页导出,自己测试的时候任然报了数组下标越界,且越界的下标为负值,文件能正常导出,但导出的文件显示已损坏,看不到数据。报错代码图片以上传,求大神解答,解答有效我微信转账请大神喝奶茶

java.lang.ArrayIndexOutOfBoundsException: -20527
at java.util.ArrayList.elementData(ArrayList.java:418)
at java.util.ArrayList.get(ArrayList.java:431)
at org.apache.poi.xssf.model.StylesTable.getFontAt(StylesTable.java:386)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.getFontAt(XSSFWorkbook.java:954)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.getFontAt(SXSSFWorkbook.java:857)
at org.apache.poi.ss.util.SheetUtil.getCellWidth(SheetUtil.java:148)
at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.updateColumnWidth(AutoSizeColumnTracker.java:367)
at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.updateColumnWidths(AutoSizeColumnTracker.java:333)
at org.apache.poi.xssf.streaming.SXSSFSheet.flushOneRow(SXSSFSheet.java:1892)
at org.apache.poi.xssf.streaming.SXSSFSheet.flushRows(SXSSFSheet.java:1871)
at org.apache.poi.xssf.streaming.SXSSFSheet.flushRows(SXSSFSheet.java:1882)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.write(SXSSFWorkbook.java:931)
at com.sinosoft.application.platform.web.action.GgReportingTemplateAction.download(GgReportingTemplateAction.java:267)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sinosoft.application.common.BaseProcessAction.execute(BaseProcessAction.java:213)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:216)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:117)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:198)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:176)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.sinosoft.application.common.CAS_LANGUATE.doFilter(CAS_LANGUATE.java:35)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.sinosoft.sysframework.web.control.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.sinosoft.application.common.CompatibleFilter.doFilter(CompatibleFilter.java:29)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.sinosoft.application.common.ValidateSalt.doFilter(ValidateSalt.java:56)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:160)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.sinosoft.application.common.LoadSalt.doFilter(LoadSalt.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

此问题已解决,导致报错的原因是sheet.trackAllColumnsForAutoSizing();poi自动设置列宽的代码,注释这行之后问题解决。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐