The Fast report is a classic reporting control, but its export functionality only supports exporting to disk files, and this project requires that the report generated by fast reports be exported to a memory stream for the purpose of bypassing permissions and for server security, so modify the fast reporting source.
The export function of Fast Report2.5 is declared in the Fr_class file, referencing this function to easily write out functions that are exported to the memory stream:
Add support for exporting to a memory stream--conch 2007-09-10--
Procedure Tfrreport.exporttostream (Filter:tfrexportfilter; Stream:tmemorystream);
Var
s:string;
Flag, Needconnect:boolean;
Begin
Docmode: = dmprinting;
Fcurrentfilter: = Filter;
if (Preview <> nil) and (Emfpages.count = 0) Then
Begin
Preview.disconnect;
Needconnect: = True;
End
Else
Needconnect: = False;
Flag: = True;
If assigned (Fcurrentfilter.onbeforeexport) then
Fcurrentfilter.onbeforeexport (Fcurrentfilter.filename, Flag);
Fcurrentfilter.stream: = Stream;
Curreport: = Self;
Masterreport: = Self;
Savedallpages: = Emfpages.count;
Fcurrentfilter.onbegindoc;
Exportbeforemodal (Self);
If assigned (Fcurrentfilter.onafterexport) then
Fcurrentfilter.onafterexport (Fcurrentfilter.filename);
If Needconnect Then
Preview.connect (Self);
Fcurrentfilter: = nil;
End
Similarly, the Tfrhtml2export control modifies the Tfrhtml2export.onenddoc function by keeping the CSS file separate from HTML, so that the HTML content in the memory stream cannot be displayed because of a lack of CSS. Find Savestringtofile (imagefolderfull + ' + cssfile, s) from this function (FR2.5 in line No. 461), instead:
if FileName <> '' then
SaveStringToFile(ImageFolderFull + '' + CSSFile, s)
else begin
s := '<style type=''text/css''>' + LF + s + LF + '</style>' + LF;
Stream.Write(s[1], Length(s));
end;