我正在尝试下载excel文件,但一直在
十六进制值0x1D是无效字符'错误
请在下面找到我的代码。
public static string GenerateRADownloadExcel(System.Data.DataTable downloadtable,long studyid, out string fileName)
{
try
{
using (var wb = new XLWorkbook())
{
wb.Worksheets.Add(downloadtable);
var raDataKey = Guid.NewGuid().ToString();
fileName = "Study_" + studyid + "_ResearchActivityData_" + DateTime.Now.ToString("ddMMyy") + "_" + DateTime.Now.ToString("HHmm");
var memoryStream = new MemoryStream();
wb.SaveAs(memoryStream);
memoryStream.Position = 0;
HttpContext.Current.Session[raDataKey] = memoryStream;
return raDataKey;
}
}
catch(Exception ex)
{
throw ex;
}
}
执行wb.SaveAs(memoryStream);