【发布时间】:2018-10-06 15:18:40
【问题描述】:
我在循环生成超过 1 个 PDF 的 Crystal 报表时遇到了困难。基本上我正在创建 PDF,然后压缩这些文件并生成 HTTP 响应。为了演示代码,我在这里运行了两次循环是我的代码。
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/zip";
Response.AppendHeader("content-disposition", "attachment; filename=Report.zip");
using (ZipFile zip = new ZipFile())
{
for (int i = 0; i < 2; i++)
{
var re = rpt.ExportToStream(ExportFormatType.PortableDocFormat);
string Name="PDF"+i+".pdf";
zip.AddEntry(Name, re);
}
zip.Save(Response.OutputStream);
}
Response.Clear();
它成功生成了 zip 文件,但是当我尝试提取它时,我给出了一个错误 No archive found (The archive is either in unknown formate or damaged). 任何帮助将不胜感激。顺便说一句,我关注了这个链接Export Crystal Report to PDF in a Loop only works with first
【问题讨论】:
标签: c# crystal-reports