Crystal Reports export to HTML

11,718

Solution 1

Report can be viewed in HTML as

    MemoryStream oStream; // using System.IO
    oStream = (MemoryStream)
    rd.ExportToStream(
    CrystalDecisions.Shared.ExportFormatType.HTML40);
    Response.Clear();
    Response.Buffer = true;
    Response.ContentType = "text/html";
    Response.BinaryWrite(oStream.ToArray());
    Response.End();

But the format may suffer.

Reference: How to Export Crystal Report in ASP.NET

Solution 2

Because you marked it up I thought I'd upgrade it to an answer for closure and the rep:

you could save the html document to disk and then use a redirect to that as a workaround but I can't find any other way of doing it. if you are going to do it that way make sure you add uniqueness to the fime name (I find datetime is a useful string) to support concurrency,

MD

Share:
11,718
Emanuele Greco
Author by

Emanuele Greco

KISS

Updated on June 15, 2022

Comments

  • Emanuele Greco
    Emanuele Greco almost 2 years

    I use CrystalReports 13 (13.0.2000.0) in an ASP.NET 4.0 application.
    I need to export report in HTML because i want a static report page, without reporviewer that allows user interaction.

    If i try the following code:

     Source1.ReportDocument.ExportToHttpResponse(  
       CrystalDecisions.Shared.ExportFormatType.HTML32   /*or HTML40*/
       , this.Response  , false, "report");
    

    Application generates an error (Detail: Export in HTTP response in HTML format is not supported.)

    If i try ReportExporter, HTML32 and HTML40 are not available ase ExportFormat.

    Can someone help?

  • Emanuele Greco
    Emanuele Greco over 12 years
    No, PDF doesn't help: actually I use PDF but IE9 x64 hasn't got PDF plugin, so some user see browser asking to download a file instead of viewing it in the browser.
  • MD-Tech
    MD-Tech over 12 years
    you could save the html document to disk and then use a redirect to that as a workaround but I can't find any other way of doing it,
  • MD-Tech
    MD-Tech over 12 years
    if you are going to do it that way make sure you add uniqueness to the fime name (I find datetime is a useful string) to support concurrency