private static void CreateRows(this HSSFWorkbook workbook, DataRowCollection rows, Dictionary <string, string> columns, string sheetName = "Sheet") { HSSFCellStyle headStyle = workbook.SetHeaderStyle(); HSSFCellStyle cellStyle = workbook.SetCellStyle(); short dateFormat = workbook.SetDateFormat(); //行首 HSSFSheet sheet = workbook.CreateSheet(sheetName); sheet.CreateHeader(columns, headStyle); int rowCount = 1; int sheetCount = 1; foreach (DataRow dr in rows) { //超出10000条数据 创建新的工作簿 if (rowCount == 65536) { rowCount = 1; sheetCount++; sheet = workbook.CreateSheet(sheetName + sheetCount); sheet.CreateHeader(columns, headStyle); } HSSFRow row = sheet.CreateRow(rowCount); row.CreateCells(dr, columns, cellStyle, dateFormat); rowCount++; } }