Page 1 of 1

Question about OnExportReportResponse

Posted: Tue Oct 30, 2018 3:43 pm
by okamashev
Hello!

As described in documentation: "To perform any actions with an already exported report, the OnExportReportResponse event is used. This event will be called immediately before the file is saved. In this event, you can get the export format, the type of the Web content and the name of the file to save. You can also get, and, if necessary, change the byte stream of the final export file."

I tried to change byte stream and it doesn't work for me (old stream saves).
My code is:

Code: Select all

  protected void Report_OnExportResponse(object sender, StiExportReportResponseEventArgs e)
        {
                Stream stream = e.Stream;
                var text = stream.ReadAll().Replace("A", "B");
                e.Stream = new MemoryStream(Encoding.UTF8.GetBytes(text ?? ""));
        }
Could you help me and say what is wrong?

Re: Question about OnExportReportResponse

Posted: Wed Oct 31, 2018 9:22 am
by Lech Kulikowski
Hello,

You can use the following code:

Code: Select all

using (var reader = new StreamReader(e.Stream))
        {
            var text = reader.ReadToEnd().Replace("A", "B");
            var result = new MemoryStream(Encoding.UTF8.GetBytes(text ?? ""));
            e.Stream.Position = 0;
            e.Stream.SetLength(result.Length);
            result.CopyTo(e.Stream);
        }
Also, we have added this task to our to-do list.

Thank you.

Re: Question about OnExportReportResponse

Posted: Wed Oct 31, 2018 10:22 am
by okamashev
Thank you for answer

But this code returns error Exception Details: System.ObjectDisposedException: Cannot access a closed Stream.
I've tried to do somethig with StreamWriter but: Exception Details: System.ArgumentException: Stream was not writable.

Re: Question about OnExportReportResponse

Posted: Thu Nov 01, 2018 8:06 am
by Lech Kulikowski
Hello,

We couldn't reproduce the issue in our samples.

Please send us a sample project which reproduces the issue for analysis.

Thank you.

Re: Question about OnExportReportResponse

Posted: Thu Nov 01, 2018 8:56 am
by okamashev
I'm sorry, everethyng works
Thank you very much

Re: Question about OnExportReportResponse

Posted: Thu Nov 01, 2018 9:33 am
by Lech Kulikowski
Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.