cancel
Showing results for 
Search instead for 
Did you mean: 

Unable ExportToStream HTML text

Former Member
0 Kudos

Hi. I am trying to export to stream HTML text with the following code:


var reportDocument = new ReportDocument();
reportDocument.Load(Server.MapPath(test_rpt file));
reportDocument.SetDataSource(test_source);
MemoryStream stream;
stream = (MemoryStream)this.reportDocument.ExportToStream(ExportFormatType.HTML32);
StreamReader reader = new StreamReader(stream);
string report = reader.ReadToEnd();
reader.Close();

But get just empty string!!!

But if I am using


reportDocument.ExportToDisk(ExportFormatType.HTML32, path_to_html)

All is working fine! Please help me to understand what is wrong?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

I've done more testing and I get the same. I believe the issue is because Streams are exported in a binary format whereas HTML is simple text. I don't think this will ever work, or work in CR.

Work around would be to use the ExporttoDisk option and then outside of CR stream the HTML files to the user using System.IO API's....

Thanks again

Don

Former Member
0 Kudos

Yes. Now I am using exactly the same approach. I am saving HTML file on the disk and then read it. But it's not suitable! I thnik Stream should be working! Will be waiting answer from CR team.

0 Kudos

If you don't want to save to local file system first and then stream the file outside of CR then that is your option. Adding 4 or 5 lines of extra code is not something considered a CR issue and that is the your work around. It works fine using any other Binary based file types.

This is by design. Add your enhancement request to [Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports] if you feel it needs to be added.

Thank you

Don

Answers (1)

Answers (1)

0 Kudos
Former Member
0 Kudos

There is no any parallels in you sample with my SAMPLE! Please read more carefully.