A report can be exposed as a web-API endpoint that renders and returns a document on demand — a lightweight export service.

Render on request and return the file. The API action picks the format from a query parameter:
[HttpGet]
public IActionResult Get(string reportName, string format = "pdf")
{
    var report = new StiReport();
    report.Load(Path.Combine("Reports", reportName + ".mrt"));
    report.Render(false);

    var stream = new MemoryStream();
    switch (format)
    {
        case "pdf":
            report.ExportDocument(StiExportFormat.Pdf, stream);
            return File(stream.ToArray(), "application/pdf");
        case "excel":
            report.ExportDocument(StiExportFormat.Excel2007, stream);
            return File(stream.ToArray(), "application/vnd.ms-excel");
        default:
            return Content($"Format [{format}] is not supported!");
    }
}

How it works. Any client can request a rendered report by URL, so exporting becomes a service other applications call directly.

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.