1

我实现了一个将水晶报表导出为 pdf 的循环。这个想法是用它的连接实例化初始报告,然后在循环中应用参数,然后再导出为 PDF(所以我为每条记录获取一个 pdf),但报告会继续使用第一个循环执行的数据导出 pdf。应用新参数后如何强制它刷新数据?

示例代码:

ReportDocument reportDoc=new ReportDocument();
reportDoc.Load("c:\\reportx.rpt");
ConnectionInfo cinfo = FunctionLibrary.getCrystalConection();
foreach (Table table in reportDoc.Database.Tables)
{
    table.LogOnInfo.ConnectionInfo = cinfo;
    table.ApplyLogOnInfo(table.LogOnInfo);
}
string[] docnumbers=new[]{"1","2","3","4"};

for(int i=0;i<docnumbers.Lenght; i++)
{
    report.SetParameterValue(0, docnumbers[i]);
    report.Refresh();
    DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
    PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
    CrDiskFileDestinationOptions.DiskFileName = "C:\\generatedpdf " + docnumbers[i] + ".pdf";
    ExportOptions CrExportOptions = reportDoc.ExportOptions;
    {
        CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
        CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
        CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
        CrExportOptions.FormatOptions = CrFormatTypeOptions;
    }
    reportDoc.Export();
}
reportDoc.Close();
4

1 回答 1

0

问题出在 report.Refresh(); 当我删除那条线时它起作用了......

于 2012-06-06T08:34:11.970 回答