Report.Export raises an exception "The path is not of a legal form" when exporting to stre

edited 12:05PM in FastReport .NET

Hi,

I get the exception "The path is not of a legal form" when I try to export a report to stream. ( Export to file works O.K. )

Here is the code that I'm using:

Report rep = new Report();
rep.Load(Request.PhysicalApplicationPath + "MyRep.frx");
rep.RegisterData(... some data ... );
rep.Prepare();
FastReport.Export.Html.HTMLExport export = new FastReport.Export.Html.HTMLExport();
MemoryStream St = new MemoryStream();
rep.Export(export, St); // this line causus an error

Any help will be appreciated,

Trebor

Comments

  • edited 12:05PM
    Hello,

    HTML export output can't be saved to a stream because it may contain several files (.html file per each report page + image files).
  • edited 12:05PM
    AlexTZ wrote: »
    Hello,

    HTML export output can't be saved to a stream because it may contain several files (.html file per each report page + image files).

    Thanks,

    I changed the HTML export filter with RTF filter, but now I'm facing another error
    ( "Cannot start process because a file name has not been provided.") when exporting to stream:

    Report rep = new Report();
    rep.Load(Request.PhysicalApplicationPath + "MyRep.frx");
    rep.RegisterData(... some data ... );
    rep.Prepare();
    FastReport.Export.RichText.RTFExport export = new FastReport.Export.RichText.RTFExport();
    MemoryStream St = new MemoryStream();
    rep.Export(export, St); // this line causes the error "Cannot start process because a file name has not been provided."

    Any help ?

  • edited 12:05PM
    Set export.OpenAfterExport to false. I will fix this later.
  • edited 12:05PM
    AlexTZ wrote: »
    Set export.OpenAfterExport to false. I will fix this later.

    Thanks,

    Now, the stream length is OK ( the same with the file length when exporting to file ), but the stream content is emtpy .
    ( When I read the stream content into byte array, the whole array is filled with bytes with value = 0 )

    FastReport.Export.RichText.RTFExport export = new FastReport.Export.RichText.RTFExport();
    export.OpenAfterExport = false;

    MemoryStream St = new MemoryStream();
    rep.Export(export, St);

    Byte[] buffer = new Byte[St.Length];
    St.Read(buffer, 0, (int)St.Length); // all the elements of the buffer are bytes with value = 0


    Any help ?


  • edited 12:05PM
    Set St.Position to 0 before read from stream.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.