Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Save an SSRS Report in html format.

Save an SSRS Report in html format.

Scheduled Pinned Locked Moved C#
htmlsql-server
5 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PhilMcGahan
    wrote on last edited by
    #1

    The code below will load an rdl report from a datasource and save it as PDF. But only PDF. If I choose any other format it errors with System.ArgumentOutOfRangeException HResult=0x80131502 Message=Specified argument was out of the range of valid values. Parameter name: format Source=Microsoft.ReportViewer.WebForms ... at Microsoft.Reporting.WebForms.Report.Render(String format, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& --- I would welcome a suggestion. Code as follows Private Sub SaveReportAsHtml(rdcFile As String, outputfolderRoot As String) 'rdcFile = = "Report001ByPhil" 'outputfolderRoot = = "C:\temp" Dim localReport As New LocalReport() localReport.ReportPath = rdcFile Dim ds As DataSet = FillADataSetWithSampleData() Dim reportDataSource As New ReportDataSource("DataSet1", ds.Tables("table1")) localReport.DataSources.Add(reportDataSource) Dim mimeType As String Dim encoding As String Dim extension As String Dim streamIds() As String Dim warnings() As Microsoft.Reporting.WebForms.Warning Dim outputFormat As String = "MHTML" 'does not work outputFormat = "HTML3.2" 'does not work outputFormat = "HTML4.0" 'does not work outputFormat = "HTMLOWC" 'does not work outputFormat = "PDF" 'works Dim bytes As Byte() = localReport.Render(outputFormat, Nothing, mimeType, encoding, extension, streamIds, warnings) Dim outputPath As String = Path.Combine(outputfolderRoot, "SSRS_output") outputPath = outputPath + "." + outputFormat DeleteFile(outputPath) Using fs As New FileStream(outputPath, FileMode.Create) fs.Write(bytes, 0, bytes.Length) End Using End Sub

    J Richard DeemingR 2 Replies Last reply
    0
    • P PhilMcGahan

      The code below will load an rdl report from a datasource and save it as PDF. But only PDF. If I choose any other format it errors with System.ArgumentOutOfRangeException HResult=0x80131502 Message=Specified argument was out of the range of valid values. Parameter name: format Source=Microsoft.ReportViewer.WebForms ... at Microsoft.Reporting.WebForms.Report.Render(String format, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& --- I would welcome a suggestion. Code as follows Private Sub SaveReportAsHtml(rdcFile As String, outputfolderRoot As String) 'rdcFile = = "Report001ByPhil" 'outputfolderRoot = = "C:\temp" Dim localReport As New LocalReport() localReport.ReportPath = rdcFile Dim ds As DataSet = FillADataSetWithSampleData() Dim reportDataSource As New ReportDataSource("DataSet1", ds.Tables("table1")) localReport.DataSources.Add(reportDataSource) Dim mimeType As String Dim encoding As String Dim extension As String Dim streamIds() As String Dim warnings() As Microsoft.Reporting.WebForms.Warning Dim outputFormat As String = "MHTML" 'does not work outputFormat = "HTML3.2" 'does not work outputFormat = "HTML4.0" 'does not work outputFormat = "HTMLOWC" 'does not work outputFormat = "PDF" 'works Dim bytes As Byte() = localReport.Render(outputFormat, Nothing, mimeType, encoding, extension, streamIds, warnings) Dim outputPath As String = Path.Combine(outputfolderRoot, "SSRS_output") outputPath = outputPath + "." + outputFormat DeleteFile(outputPath) Using fs As New FileStream(outputPath, FileMode.Create) fs.Write(bytes, 0, bytes.Length) End Using End Sub

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      Google

      visual basic "LocalReport" render "Specified argument was out of the range of valid values."

      From that and this very site https://www.codeproject.com/Questions/1130614/How-to-render-localreport-to-HTML-using-csharp It says you can't do what you are attempting. I did not verify the answer.

      P 1 Reply Last reply
      0
      • P PhilMcGahan

        The code below will load an rdl report from a datasource and save it as PDF. But only PDF. If I choose any other format it errors with System.ArgumentOutOfRangeException HResult=0x80131502 Message=Specified argument was out of the range of valid values. Parameter name: format Source=Microsoft.ReportViewer.WebForms ... at Microsoft.Reporting.WebForms.Report.Render(String format, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& --- I would welcome a suggestion. Code as follows Private Sub SaveReportAsHtml(rdcFile As String, outputfolderRoot As String) 'rdcFile = = "Report001ByPhil" 'outputfolderRoot = = "C:\temp" Dim localReport As New LocalReport() localReport.ReportPath = rdcFile Dim ds As DataSet = FillADataSetWithSampleData() Dim reportDataSource As New ReportDataSource("DataSet1", ds.Tables("table1")) localReport.DataSources.Add(reportDataSource) Dim mimeType As String Dim encoding As String Dim extension As String Dim streamIds() As String Dim warnings() As Microsoft.Reporting.WebForms.Warning Dim outputFormat As String = "MHTML" 'does not work outputFormat = "HTML3.2" 'does not work outputFormat = "HTML4.0" 'does not work outputFormat = "HTMLOWC" 'does not work outputFormat = "PDF" 'works Dim bytes As Byte() = localReport.Render(outputFormat, Nothing, mimeType, encoding, extension, streamIds, warnings) Dim outputPath As String = Path.Combine(outputfolderRoot, "SSRS_output") outputPath = outputPath + "." + outputFormat DeleteFile(outputPath) Using fs As New FileStream(outputPath, FileMode.Create) fs.Write(bytes, 0, bytes.Length) End Using End Sub

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        LocalReport.Render Method (String, String, CreateStreamCallback, out Warning ) (Microsoft.Reporting.WinForms) | Microsoft Learn[^]:

        Supported formats include Excel, PDF, Word, and Image.

        Note that this specifically does not mention HTML in any form. You can use the LocalReport.ListRenderingExtensions method[^] to get the list of supported formats.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        P 1 Reply Last reply
        0
        • J jschell

          Google

          visual basic "LocalReport" render "Specified argument was out of the range of valid values."

          From that and this very site https://www.codeproject.com/Questions/1130614/How-to-render-localreport-to-HTML-using-csharp It says you can't do what you are attempting. I did not verify the answer.

          P Offline
          P Offline
          PhilMcGahan
          wrote on last edited by
          #4

          Thank you that was very helpful.

          1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            LocalReport.Render Method (String, String, CreateStreamCallback, out Warning ) (Microsoft.Reporting.WinForms) | Microsoft Learn[^]:

            Supported formats include Excel, PDF, Word, and Image.

            Note that this specifically does not mention HTML in any form. You can use the LocalReport.ListRenderingExtensions method[^] to get the list of supported formats.


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            P Offline
            P Offline
            PhilMcGahan
            wrote on last edited by
            #5

            Thank you. That was very helpful.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups