Export formats
Return a report as PDF, Excel or Word from the same render call.
Choose a ReportFormat when you call RenderAsync.
ReportFormat.Pdfis the default. The PDF uses the engine’s page layout and embeds the font characters used in the report.ReportFormat.Excelcreates an.xlsxfile with one sheet. It shows page headers once and leaves out page footers. Numbers and dates stay typed so you can sort or total them in Excel.ReportFormat.Wordcreates a.docxfile with a section for each page. Text frames, lines and boxes follow the positions in the PDF.
Use ReportFormats to get the content type and file extension for your response.
var format = ReportFormat.Excel;
var bytes = await reports.RenderAsync("sales-summary", rows, new { FromDate = from, ToDate = to }, format, ct);
return File(bytes, ReportFormats.ContentType(format), "sales-summary" + ReportFormats.FileExtension(format));
The sample web app takes ?format=pdf, ?format=xlsx or ?format=docx. You can also pass those values to the report server.