HTMLExport using memorystream

Posted by: steve.humpal on 13 March 2018, 8:23 am EST

    • Post Options:
    • Link

    Posted 13 March 2018, 8:23 am EST

    The goal is to use ActiveReports 7 to generate a web page version of the report. We currently use the PDF Export to serve up reports on the web in PDF format, but we would like to have the option to display the same reports as web pages.

    I’ve used the htmlExport class to export to a file with an htm extension and that works fine for what it does, but it leaves files behind. I’d like this process to be dynamic. I see the HtmlExport class supports exporting to a memorystream. This stream seems to be a multipart/related mime type. How does one display the stream in a browser?

    For example I was trying to use the WebBrowser control in a windows form but not having any luck getting it to display.

    using (var memoryStream = new MemoryStream())

    using (var htmlExporter = new HtmlExport())

    {

    htmlExporter.Export(report.Document, memoryStream);

    webBrowser1.DocumentStream = memoryStream;

    webBrowser1.DocumentStream.Flush();

    }

    Any help would be greatly appreciated.

  • Posted 13 March 2018, 4:17 pm EST

    Hello,

    The behaviour you see is the design behaviour of the HtmlExport class. When exporting to a stream, it exports to mht format and when exporting to a file, it exports to Html format.

    Unfortunately, there’s no other workaround except for the workaround you’re already using to save it into a file and then load it into a stream.

    I apologize for the inconvenience.

    Thanks,

    Mohit

  • Posted 15 March 2018, 1:58 am EST

    Mohit,

    Thanks for the reply. If the stream is an MHT file then I should be able to save the stream bytes to a file with a *.mht extension and open it in IE or Chrome, right? However, when I try this the resulting mht file won’t display in either browser.

    I saved a regular web page from IE to an mht file to compare the source and as far as I can tell the ActiveReports htmlexport file follows a similar pattern for the multipart mime message.

    What am I missing? If the stream is a valid MHT file then what I was doing in my original post should have worked, right?

    Thanks,

    Steve

  • Posted 15 March 2018, 6:21 pm EST

    Hello,

    I am unable to replicate the problem using the following code:

    
    
                using (var memoryStream = new MemoryStream())
                {
                    using (var htmlExporter = new GrapeCity.ActiveReports.Export.Html.Section.HtmlExport())
                    {
                        htmlExporter.OutputType = GrapeCity.ActiveReports.Export.Html.Section.HtmlOutputType.LegacyHtml;
                        htmlExporter.IncludeHtmlHeader = true;
                        htmlExporter.Export(sectionReport.Document, memoryStream);
                        memoryStream.Seek(0, SeekOrigin.Begin);
                        FileStream file = new FileStream("d:\\file.mht", FileMode.Create, FileAccess.Write);
                        memoryStream.WriteTo(file);
                        file.Close();
                    }
                }
    
    

    Could you please share the stripped down sample, so that I can replicate at my end. Also, please share the exact version of that you are using.

    Please refer the attached file which created through above code.

    Thanks,

    Mohitfile.zip

  • Posted 19 March 2018, 3:11 am EST

    Mohit,

    I’ve done more testing on this with the CalculatedFields sample project that came with ActiveReports 7. I’m able to reproduce the issue using the sample project.

    I tried the same code in the ActiveReports 12 CalculatedFields sample and it works. I also used the AR12 version against my saved rpx file and it worked also.

    At this point I think there may be a bug in HTMLExport for AR7. We are using version 7.3.7973.0. Can you please try to repro using that version?

    Thanks,

    Steve

  • Posted 19 March 2018, 4:57 am EST

    Mohit,

    Attached are the files created from AR7 vs AR12.

    file.mht - AR12 version

    file2.mht AR7 version

    Thanks,

    Steve

    file.zip

  • Posted 19 March 2018, 8:10 pm EST

    Hello,

    We understand this is bug in AR7. However, AR7 had declared as a legacy product a long time ago and it is out of development mode. You need to update to our latest release(AR12) as no fixing will be done in AR7.

    Sorry for the inconvenience caused.

    Thanks,

    Mohit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels