Exporting a Report from Code
Our sample projects and report templates can help you learn the basics of working with our products.A rendered report can be sent straight to the printer or exported to any supported format from code — no viewer required.
Print. Load, then call
How it works. Rendering is separated from output, so the same prepared report can be printed and exported to several formats without rebuilding it.
Print. Load, then call
Print():var report = new StiReport();
report.Load(@"Reports\TwoSimpleLists.mrt");
report.Print();Export. Render first, then write the document to a stream in the chosen format:var report = new StiReport();
report.Load(@"Reports\TwoSimpleLists.mrt");
report.Render();
var stream = new MemoryStream();
report.ExportDocument(StiExportFormat.Pdf, stream); // or Word2007, Excel2007, ...Render()— builds the document pages in memory; required before exporting.ExportDocument(StiExportFormat, stream)— writes the result; theStiExportFormatenum selects PDF, Word, Excel, HTML and more.Print()— renders and prints in one call.
How it works. Rendering is separated from output, so the same prepared report can be printed and exported to several formats without rebuilding it.