Export and print
ArionUI.Export · free during the preview, also commerciallyThe current view as CSV, XLSX or PDF, and the same view cut into pages for a print dialog. What is exported is what the user sees: the rows after filtering and sorting, the visible columns in their order.
Install
dotnet add package ArionUI.Export --prereleaseThe export calls are extension methods on GridView<T> in the namespace ArionUI.Export; calling one switches the module on.
To a file
view.ExportCsvToFile("orders.csv"); // UTF-8 with BOM, the culture's list separator
view.ExportXlsxToFile("orders.xlsx");
view.ExportPdfToFile("orders.pdf", new PrintOptions
{
Title = "Open orders",
Landscape = true,
FitToPageWidth = true,
});The …ToFile methods write to a file next to the target and move it into place only after the last row. If your code throws while a value is read, the half-written file is deleted and an existing target is left as it was. The exception itself reaches you.
- CSV
- UTF-8 with a byte-order mark by default, which Excel needs to open a CSV as Unicode; the culture's list separator; quoting per RFC 4180. Group rows are left out.
- XLSX
- One worksheet with the visible columns. Number columns become numeric cells that Excel can sum. A grouped view keeps its groups as an Excel outline: each group header carries its label, count and aggregates, its rows sit one level deeper, and collapsed groups are exported in full.
- Rows cut into pages, the column header repeated on each page, a page line at the bottom. Text stays text — searchable and selectable. Cells are drawn by the same templates as on screen, so a badge or a sparkline looks on paper as it does in the grid. A grouped view prints every group expanded.
To a stream
view.ExportXlsx(stream); // to any stream: a response, a blob, memory
using (var writer = new StringWriter())
{
view.ExportCsv(writer);
}With a stream or writer of your own, what has been written when a value throws stays written — the sink is yours, and so is its cleanup.
Page setup
PrintOptions sets the page size in points (A4 by default), Landscape, Margin, a Title printed on every page, FitToPageWidth to shrink a wide table onto the page instead of cutting it at the margin, and a Theme — the light built-in theme by default, because paper is white whatever the screen is.
Printing
GridPrintDocument document = view.Paginate(new PrintOptions { Title = "Open orders" });
int pages = document.PageCount;
// document.RenderPage(surface, page) draws one page onto any IRenderSurfacePaginate lays the view out on pages and hands you a GridPrintDocument that draws any page onto an IRenderSurface. That is everything a print dialog needs; the dialog itself belongs to your host framework. The page line ("page 1 of 3") comes from ArionUiText.PrintPageOf and is German by default.
