This example shows how to render report in the console app. First, use
Load()
method to load report template, after that, use
ExportDocument()
method to Export it to PDF:
static void Main(string[] args)
{
Console.WriteLine("Hello!");
Console.Write("Loading report and data... ");
var report = new StiReport();
report.Load($"{ReportsDirectory}/TwoSimpleLists.mrt");
Console.WriteLine("OK");
Console.Write("Rendering and exporting a report... ");
var exportFilePath = $"{ReportsDirectory}/TwoSimpleLists_{DateTime.Now.ToString("yyyy-dd-MM_HH-mm-ss")}.pdf";
report.Render(false);
report.ExportDocument(StiExportFormat.Pdf, exportFilePath);
Console.WriteLine("OK");
Console.WriteLine("Exported to:");
Console.WriteLine(Path.GetFullPath(exportFilePath));
Console.ReadKey();
}
In the screenshot below you can see the result of the sample code: