public bool ToExcel(DataTable table,DataTable headtable,string filePath,string title)
{
int sheetexportnum = 60000;
FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
IWorkbook workBook = new HSSFWorkbook();
int count = table.Rows.Count;
int sheetcount =0;
if (table.Rows.Count%sheetexportnum ==0) {
sheetcount = Convert.ToInt16(Math.Floor(Convert.ToDouble(table.Rows.Count / sheetexportnum)));
}
else {
sheetcount = Convert.ToInt16(Math.Floor(Convert.ToDouble(table.Rows.Count / sheetexportnum))) + 1;
}
for (int m = 1; m <= sheetcount; m++)
{
ISheet sheet = workBook.CreateSheet("sheet"
C#百万级数据导出到EXCEL分多个sheet保存
最新推荐文章于 2024-05-09 15:26:51 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)