https://fastreports.github.io/FastReport.Documentation/Exporting.html
FastReport Open Source can save documents in HTML, BMP, PNG, JPEG, GIF, TIFF, EMF.
The following is an example of exporting a report in Jpeg file.
using FastReport; using FastReport.Utils; using FastReport.Export.Image; ... // Create new Report Report report = new Report(); // Load report from file report.Load("report.frx"); // Set the parameter report.SetParameterValue("MYPARAMETER", 1024); // Prepare the report report.Prepare(); // Export in Jpeg ImageExport image = new ImageExport(); image.ImageFormat = ImageExportFormat.Jpeg; // Set up the quality image.JpegQuality = 90; // Decrease a resolution image.Resolution = 72; // We need all pages in one big single file image.SeparateFiles = false; report.Export(image, "report.jpg");
The following is an example of exporting a report in PNG file.
1 // Export in PNG 2 ImageExport image = new ImageExport(); 3 image.ImageFormat = ImageExportFormat.Png; 4 // Increase a resolution 5 image.Resolution = 300; 6 // We need separate file for each report page, they will be numbered: report.png, report.2.png, report.3.png, etc. 7 image.SeparateFiles = true; 8 report.Export(image, "report.png");
The following is an example of exporting a report in HTML file.
1 using FastReport; 2 using FastReport.Utils; 3 using FastReport.Export.Html; 4 ... 5 // Export in HTML 6 HTMLExport html = new HTMLExport(); 7 // We need embedded pictures inside html 8 html.EmbedPictures = true; 9 // Enable all report pages in one html file 10 html.SinglePage = true; 11 // We don't need a subfolder for pictures and additional files 12 html.SubFolder = false; 13 // Enable layered HTML 14 html.Layers = true; 15 // Turn off the toolbar with navigation 16 html.Navigator = false; 17 // Save the report in html 18 report.Export(html, "report.html");View Code
The following is an example of exporting a report in multiple streams.
1 // Creatint the Report object 2 using (Report report = new Report()) 3 { 4 // Loading a report 5 report.Load("report.frx"); 6 // Preparing a report 7 report.Prepare(); 8 9 // Creating the HTML export 10 using (HTMLExport html = new HTMLExport()) 11 { 12 // Choose the Jpeg pictures 13 html.ImageFormat = ImageFormat.Jpeg; 14 // We need the saving in multiple streams 15 html.SaveStreams = true; 16 // Exporting with fake null stream object, html export will keep all files inside 17 report.Export(html, (Stream)null); 18 // Checking for the exporting 19 if (html.GeneratedFiles.Count > 0) 20 { 21 // Loop for generated files 22 for (int i = 0; i < html.GeneratedFiles.Count; i++) 23 { 24 // We have several streams, let's save it in files 25 using (FileStream file = new FileStream("export_path/" + html.GeneratedFiles[i], FileMode.Create)) 26 { 27 // You need reset the internal stream position 28 html.GeneratedStreams[i].Position = 0; 29 // Saving a stream in the file 30 html.GeneratedStreams[i].CopyTo(file); 31 } 32 } 33 } 34 } 35 }View Code
标签:image,FastReport,html,file,Exporting,report,using From: https://www.cnblogs.com/xychen/p/18200059