poi框架excel导出合并列

xiaoxiao2021-03-01  9

HSSFRow row = sheet.createRow(i);     for (int j = 0; j < headerRow.size(); j++) {      HashMap map=(HashMap) headerRow.get(j);       short rowspan=Short.valueOf( map.get("rowspan")+"");       short rowend=(short)(rowstart+rowspan-1);       HSSFCell cell = row.createCell((short)rowstart);       //导出前先设置,而且值设置在第一个框中       cell.setCellValue(new String(String.valueOf(map.get("value")).getBytes(),"UTF-8"));

 

cell.setEncoding(HSSFCell.ENCODING_UTF_16);//设置单元格编码防止乱码

 

       //四个参数分别是:起始行,起始列,结束行,结束列         sheet.addMergedRegion(new Region(colstart, rowstart, colend,rowend ));                      // cell.setCellStyle(HSSFCellStyle.)                                   rowstart=(short)(rowend+1);                          }       colstart=colend+1;             }

转载请注明原文地址: https://www.6miu.com/read-3650274.html

最新回复(0)