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();
}
На скриншоте ниже Вы можете увидеть результат выполнения данного кода: