0

I want to export a multi page report (FastReport) to image

var stream = new MemoryStream();
rpt.Export(new ImageExport(), result);

reports with one page is OK, but multipage reports have this error :

empty path name is not legal

Have any idea to solve this?!

4

1 回答 1

0

您应该使用路径,而不是流。

路径示例:

using (FastReport.Report report = new FastReport.Report())
{
    report.Load(@"C:\test.frx");

    report.Prepare();                               
    report.Export(new FastReport.Export.Image.ImageExport(), "myReport.png");             
}

当报告超过一页时,将创建以下文件:

myReport.png
myReport.2.png
myReport.3.png
...

这是带有流的解决方案。您应该设置PageRange = PageRange.Current并设置CurPage为适当的值:

int count = 1;
using (FastReport.Report report = new FastReport.Report())
{
    report.Load(@"C:\test.frx");
    report.Prepare();

    foreach (PageBase item in report.Pages)
    {
        string fileName = string.Format("myReport_{0}.png", count);
        report.Export(new FastReport.Export.Image.ImageExport() { PageRange = PageRange.Current, CurPage = count }, fileName);
        count++;
    }
}
于 2013-10-28T19:50:01.963 回答