c#导出到System.OutOfMemoryException中的excel

c#导出到System.OutOfMemoryException中的excel,c#,asp.net,excel,exception,openxml,C#,Asp.net,Excel,Exception,Openxml,我有一个计划: 1.对MSSQL执行sql查询 2.将sql查询中的行插入excel 3.通过邮件发送excel文档 如果要插入excel文档的行数超过100000,则会发生错误:System.OutOfMemoryException 我在projectproperties-platformtarget=x64中设置了该值,但没有帮助 使用(SqlConnection sqlConn=newsqlconnection(connectionString)) 使用(SqlCommand cmd=n

我有一个计划: 1.对MSSQL执行sql查询 2.将sql查询中的行插入excel 3.通过邮件发送excel文档
如果要插入excel文档的行数超过100000,则会发生错误:System.OutOfMemoryException 我在projectproperties-platformtarget=x64中设置了该值,但没有帮助

使用(SqlConnection sqlConn=newsqlconnection(connectionString))
使用(SqlCommand cmd=newsqlcommand(Qry,sqlConn))
{
sqlConn.Open();
cmd.CommandTimeout=0;
{
string Recipients=configMan.GetAppSetting(“收件人”);
字符串“=”;
字符串Subject=configMan.GetAppSetting(“Subject”);
弦体;
if(string.IsNullOrWhiteSpace(Recipients)| | Recipients.IndexOf('@')=-1)
{
}
Body=$“{Subject}{configMan.GetAppSetting(“Body”)}”;
字符串fileExcel=configMan.GetAppSetting(“FilePathNameExcel”);
int iCount;
ExcelLibSql excelLib=新的ExcelLibSql();
iCount=excelLib.SaveFromSQLToNewExcelNewSheet(cmd,fileExcel,“报告”,日志);
List arrAttachFiles=新列表();
if(File.Exists(fileExcel))
{
arattachfiles.Add(fileExcel);
}
其他的
{
}
如果(CcRecipients.Length>0)
{
CCR+=“;”;
}
CcRecipients+=configMan.GetAppSetting(“RecipientsTEST”);
if(configMan.GetAppSetting(“Test”)=“True”)
{
Body=“ПСС.

“+”收件人:“+Recipients+”
CcRecipients:“+CcRecipients+”

”+Body; Recipients=configMan.GetAppSetting(“RecipientsTEST”); ccc=”; } if(ews.SendMessage(日志、收件人、CcRecipients、主题、正文、BodyType.HTML、arrAttachFiles)) { log.WriteToFile($“发送邮件:{Recipients}复制:{CcRecipients}”,true); } }
}
您是否检查了ExcelLibSql如何处理SaveFromSqltoneWebExcelNewsheet?OutOfMemoryException可能来自这里我的答案可能很有用,它直接使用OpenXml-