none
Export Local Reporting Services report to PNG,JPG or GIF RRS feed

  • Question

  •  

    Is there a way to export or control the export of a report to another image file fomat other then tiff? I use this code:

     

    Code Block

    Dim byt() As Byte = Me.ReportViewer1.LocalReport.Render("Image", "", Nothing, Nothing, Nothing, Nothing, Nothing)

    Using writer As New IO.FileStream("c:\test.tiff", IO.FileMode.CreateNew)

    writer.Write(byt, 0, byt.Length)

    End Using

     

     

     

     

    Pretty simple! but I'm not sure how to do any other format. I'm sure I'm overlooking the obvious...

     

    Does anyone have any pointers?

     

    I did a search here at these forums for export png but didn't see anything (I always fear I'm doing the search wrong and the answer is looking me right in the face)

    Tuesday, October 9, 2007 2:07 AM

Answers

  •  

    An even better way to do this:

     

    Code Block

    Using rv As New Microsoft.Reporting.WebForms.LocalReport

     rv.ReportPath = Server.MapPath("~/Temp.rdlc")

     Dim byts() As Byte 

     byts = rv.Render("Image", "<DeviceInfo><OutputFormat>PNG</OutputFormat></DeviceInfo>", Nothing, Nothing, Nothing, Nothing, Nothing)

     My.Computer.FileSystem.WriteAllBytes("c:\test.png", byts, False)

    End Using

     

     

    Here is a URL to learn more about these device info XML strings:

    http://msdn2.microsoft.com/en-us/library/ms155397.aspx

    Tuesday, October 9, 2007 6:24 PM

All replies

  •  

    Here is a solution but it seems like extra processing.

     

    Code Block

    Using local As New Microsoft.Reporting.WebForms.LocalReport

    local.ReportPath = "Report.rdlc"

      Dim byts() As Byte = local.Render("Image", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)

      Using ms As New IO.MemoryStream(byts)

        Using bmp As New Drawing.Bitmap(ms)

          bmp.Save("c:\test.gif", System.Drawing.Imaging.ImageFormat.Gif)

        End Using

      End Using

    End Using

     

    Tuesday, October 9, 2007 2:34 AM
  •  

    An even better way to do this:

     

    Code Block

    Using rv As New Microsoft.Reporting.WebForms.LocalReport

     rv.ReportPath = Server.MapPath("~/Temp.rdlc")

     Dim byts() As Byte 

     byts = rv.Render("Image", "<DeviceInfo><OutputFormat>PNG</OutputFormat></DeviceInfo>", Nothing, Nothing, Nothing, Nothing, Nothing)

     My.Computer.FileSystem.WriteAllBytes("c:\test.png", byts, False)

    End Using

     

     

    Here is a URL to learn more about these device info XML strings:

    http://msdn2.microsoft.com/en-us/library/ms155397.aspx

    Tuesday, October 9, 2007 6:24 PM