https://www.codeproject.com/Tips/715976/Solutions-to-Merge-Multiple-Excel-Worksheets-int
这个只能合并数据,没有保留样式和单元格合并的,有类似的样例吗
private void cleanBeforeMergeOnValidCells(XSSFSheet sheet,CellRangeAddress region, XSSFCellStyle cellStyle ) { for(int rowNum =region.getFirstRow();rowNum<=region.getLastRow();rowNum++){ XSSFRow row= sheet.getRow(rowNum); if(row==null){ sheet.createRow(rowNum); logger.trace("while check row "+rowNum+" was created"); } for(int colNum=region.getFirstColumn();colNum<=region.getLastColumn();colNum++){ XSSFCell currentCell = row.getCell(colNum); if(currentCell==null){ currentCell = row.createCell(colNum); logger.trace("while check cell "+rowNum+":"+colNum+" was created"); } currentCell.setCellStyle(cellStyle); } } }
说白了就是单独处理。