Commit c9540508 by guojuxing

excel合并单元格修复

parent 4d04f783
...@@ -222,8 +222,11 @@ public class ExcelUtils { ...@@ -222,8 +222,11 @@ public class ExcelUtils {
n++; n++;
continue; continue;
} }
//创建第一行大标题 if (n != 1) {
sheet.addMergedRegion(new CellRangeAddress(0, 0, n, (n + sonHeader.size() - 1))); //如果n = 1,就是一个单元格,合并操作会报错
//创建第一行大标题
sheet.addMergedRegion(new CellRangeAddress(0, 0, n, (n + sonHeader.size() - 1)));
}
//赋值 //赋值
for (int j = 0, sonLength = sonHeader.size(); j < sonLength; j ++) { for (int j = 0, sonLength = sonHeader.size(); j < sonLength; j ++) {
Cell cell2 = row2.createCell(n++); Cell cell2 = row2.createCell(n++);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment