以下是 Export ActionResult 到 PDF :
List<DailySum> lstDailySum = db.DailySum.Include(x => x.codeACl).Include(x => x.codeCou).Include(x => x.codeAgc).Include(x => x.AInfo).ToList();
GridView gv = new GridView();
if (Session["Paging"] == null)
{
gv.DataSource = lstDailySum;
}
else
{
gv.DataSource = Session["Paging"];
}
gv.DataBind();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=DailySumExport.pdf");
Response.ContentType = "application/pdf";
Response.Charset = "";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gv.RenderControl(htw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
现在,当我尝试导出到Excel时,此功能正常,但当我尝试导出为PDF时,我收到此错误消息:
Adobe Acrobat Reader DC无法打开&#39; DailySumExport.pdf&#39;因为它不支持文件类型或文件已损坏(例如,它是作为电子邮件附件发送的,并且未正确解码)。
非常感谢有关如何解决此问题的任何帮助。
感谢。