ASP.NET 将一个DataTable中的数据源导出多个EXCEL中,不是多个Sheet?怎么做啊?

2024-12-04 21:29:27
推荐回答(2个)
回答1:

创建3个workbook对象分别把他们导出到这三个中

比如:
var aplExcel = newApplication {DisplayAlerts = false, SheetsInNewWorkbook = 3};
var workBook = (_Workbook)aplExcel.Workbooks.Add(Missing.Value);
var activateSheet = (_Worksheet)workBook.Sheets[1];
activateSheet.Activate();
workBook.SaveAs(excelFilePath,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

workBook.Close();
可以创建出来一个excel再把数据贴上去,再按你要的要求循环三次

回答2:

读一行,导出一个excel