Search code examples
c#reportviewer

ReportViewer Render() export directy to file stream


I want to export the reprot directly to file stream with the the ReportsViewer Render() method. I'm using the ReportViewer in LocalMode.

Here's the method declaration according to MSDN

byte[] Render (
    string format,
    string deviceInfo,
    out string mimeType,
    out string encoding,
    out string fileNameExtension,
    out string[] streams,
    out Warning[] warnings
)

The problem with this method is that te byte[] is written into the memory and after that written into a file by me. In my case with a very large report, there's way too much data in the memory and will probably cause OutOfMemoryExceptions on the prod system. Is there anyway to make the report render directly into a file ? Thanks.


Solution

  • This Render overload will do the trick

    public void Render (
        string format,
        string deviceInfo,
        CreateStreamCallback createStream,
        out Warning[] warnings
    )
    

    MSDN link - http://msdn.microsoft.com/en-us/library/ms252172%28v=vs.90%29.aspx