Pre Merge pull request !319 from ggg444/N/A

This commit is contained in:
ggg444 2021-09-25 09:14:12 +00:00 committed by Gitee
commit 9f53769f1b

View File

@ -473,8 +473,8 @@ public class ExcelUtil<T>
public void writeSheet() public void writeSheet()
{ {
// 取出一共有多少个sheet. // 取出一共有多少个sheet.
double sheetNo = Math.ceil(list.size() / sheetSize); int sheetNo = Math.max(1, (int)Math.ceil(list.size() * 1.0 / sheetSize));
for (int index = 0; index <= sheetNo; index++) for (int index = 0; index < sheetNo; index++)
{ {
createSheet(sheetNo, index); createSheet(sheetNo, index);
@ -1125,12 +1125,12 @@ public class ExcelUtil<T>
* @param sheetNo sheet数量 * @param sheetNo sheet数量
* @param index 序号 * @param index 序号
*/ */
public void createSheet(double sheetNo, int index) public void createSheet(int sheetNo, int index)
{ {
this.sheet = wb.createSheet(); this.sheet = wb.createSheet();
this.styles = createStyles(wb); this.styles = createStyles(wb);
// 设置工作表的名称. // 设置工作表的名称.
if (sheetNo == 0) if (sheetNo == 1)
{ {
wb.setSheetName(index, sheetName); wb.setSheetName(index, sheetName);
} }