TsgcHTMLReport
Banded reports to PDF
The engine behind the viewer is a non visual component of its own. It writes the PDF with TsgcHTMLExportPDF, the PDF engine of sgcHTML, and the same report can also be written as an Excel sheet.
Bands
A report header, page headers, nested groups with headers and footers, detail rows, page footers and a report footer. Group headers can repeat on every new page, KeepTogether keeps a group on one page, NewPageBefore and NewPageAfter break pages, and a report header with NewPageAfter is a cover page.
Items
Bands hold text, images, lines, rectangles, charts, rich text, barcodes, QR codes and subreports. Text is clipped to its box, and items with AutoHeight grow the band to fit the wrapped text.
Expressions and PrintIf
Texts hold expressions between [ ]: fields with a mask such as [Amount:#,##0.00], [Sum(Field)], [Count], [Avg(Field)], [Min(Field)], [Max(Field)], [RunningSum(Field)], [Page] of [Pages], [Param.Name] and [GroupValue]. Bands and items print only when their PrintIf condition is true, such as Amount > 1000.
Data sources
The rows come from a DataSet, a Grid, a JSON array in RowsJSON or the OnGetRow event. LoadFromGrid builds a table report of the columns of a TsgcHTMLComponent_Grid, with the captions on every page, zebra rows, the totals of the numeric columns and page numbers.
Charts, barcodes and QR codes
A chart item draws the rows of its band as vector graphics: bar, horizontal bar, stacked bar, line, area, pie or doughnut, one chart per group in a group band. ChartSource prints a TsgcHTMLComponent_Chart as the web page shows it. Barcode items draw Code 128, and QR code items use error correction level M.
Subreports and rich text
A subreport item prints another report inside its band, such as the lines of an order, linked to the master row by LinkFields, up to 5 levels deep, and continues on the next pages. A rich text item prints HTML, and with AutoHeight it flows across pages after the page headers.
Fonts and languages
Items print with the Base-14 fonts by default, which hold the characters of Windows-1252. Register TrueType fonts in Fonts to print Cyrillic, Greek, Arabic, Hebrew, Chinese, Japanese, Korean or symbols. Only the glyphs printed are embedded, and FallbackFonts and AutoFallback cover the characters a font lacks.
Same output everywhere
Numbers and dates print with DecimalSeparator, ThousandSeparator, DateFormat and TimeFormat of the report, never with the regional settings of the machine, so a report prints the same on every computer and on .NET. With a fixed CreationDate the same input gives the same PDF bytes.
Definition as JSON
SaveToJSON writes the page setup, fonts, bands, items and parameters, and LoadFromJSON reads them back after it validates the whole definition, with the JSON path of any error. Users design reports in the browser with the Report Designer, and a double click on the report opens the same designer in the Delphi IDE.
One report, many requests
Generate, SaveToFile, SaveToStream, GetPDFBytes, ExportToXLSX and HasData each build their own copy of the rows and the layout. One report serves several requests of a web server at the same time, each one filtered with its own parameters, with no lock of your own.