Expand description
RavenRS Reporting: banded reports, defined as data, paginated into documents that the viewer shows and the exporters write.
Reportis the definition. It covers the page, bands, groups, controls, styles, parameters, calculated fields and data sources, and is saved as JSON or built in code.ReportEnginebinds data to it and produces aDocument: pages of positioned text, lines and shapes, in points.- Expressions come from
ravenrs_criteria:[Price] * [Quantity],Sum([Total]),Iif(...),FormatString('{0:C2}', ...).
use ravenrs_report::{Band, Control, Group, Report, ReportEngine, Style};
use serde_json::json;
let report = Report::new("Sales")
.culture("pt-BR")
.group(
Group::new("[Region]")
.header(Band::new(22.0).control(Control::field("[Region]").at(0.0, 0.0, 300.0, 22.0).style(Style::new().bold())))
.footer(Band::new(20.0).control(Control::field("Sum([Amount])").format("C2").at(0.0, 0.0, 300.0, 20.0))),
)
.detail(Band::new(18.0).control(Control::field("[Customer]").at(12.0, 0.0, 300.0, 18.0)));
let data = json!([
{ "Region": "Sul", "Customer": "Ana", "Amount": 10.5 },
{ "Region": "Norte", "Customer": "Bruno", "Amount": 20 },
{ "Region": "Sul", "Customer": "Carla", "Amount": 4.5 },
]);
let doc = ReportEngine::new().render(&report, &data);
assert_eq!(doc.page_text(0), ["Norte", "Bruno", "R$\u{a0}20,00", "Sul", "Ana", "Carla", "R$\u{a0}15,00"]);Re-exports§
pub use ravenrs_criteria as criteria;
Modules§
- barcode
- Barcodes: turns text into the modules a scanner reads. Pure logic, so every output draws the same code and it can be tested without drawing.
- base64
- Base64, for images carried in layouts and in printable HTML.
- chart
- Chart layout: turns aggregated numbers into shapes and labels. Pure logic, kept apart from the engine so it can be tested without rendering a report.
- samples
- Ready-made reports with sample data: the designer’s templates, the benchmarks’ workloads and living documentation of the report model.
- vector
- Vector shapes: curves and polygons that PDF and SVG write as they are, and that the screen and spreadsheets get as a picture.
- wizard
- The report wizard: a finished table report from a data source and a choice of fields, like the wizards of commercial report designers. Also lists the fields a data source offers, for field lists.
Structs§
- Band
- A horizontal strip of the page holding controls.
- Barcode
- A barcode.
- Bookmark
- An entry in the document’s outline.
- Calculated
Field - A field computed from an expression.
- Chart
- A chart.
- Chart
Series - A chart’s series.
- Check
Box - A check box.
- Control
- A printable element of a band.
- Culture
- Number, currency and date conventions of a language and region.
- Data
Source - A named source of report data, stored with the layout.
- Date
Time - A calendar date with an optional time of day, without a time zone.
- Detail
Report - Master-detail: a nested list printed after each row of the report.
- Document
- A paginated document.
- Document
Image - A decoded image, with the file it came from: exporters can embed the file itself, which keeps JPEG photos small and unchanged. Clones share the data.
- Formatting
Rule - Formatting applied when a condition holds.
- Group
- A grouping level with its header and footer.
- Label
- Text content of a label or table cell.
- Line
- A line.
- Link
Label - A label that is also a link.
- Page
- One page.
- Page
Settings - Paper size and margins, in points.
- Panel
- A container of controls.
- Parameter
- A value supplied when the report runs.
- Parse
Error - A syntax error, with the byte offset where it was found.
- Picture
- A picture.
- Placed
Line - A line of text at its position on the page.
- Render
Options - Settings for one run of a report.
- Report
- A banded report definition.
- Report
Engine - Renders reports. Keep one around: it caches fonts and text measurements.
- Shape
- A rectangle or ellipse, filled with the style’s background and outlined with its border.
- Sort
Field - A sort key.
- Style
- Appearance settings. Every field is optional so styles can be layered: built-in defaults, then a named style, then the control’s own settings, then conditional rules.
- Table
- A table of label cells.
- Table
Cell - A table cell.
- Table
Row - A table row; its height grows to its tallest cell.
- Text
Block - Text already broken into lines and positioned.
Enums§
- Control
Kind - The kinds of controls.
- Criteria
- A parsed expression or filter.
- Data
Source Kind - How a data source obtains its data.
- Image
Format - The file format of a
DocumentImage. - Item
- A printed primitive.
- Line
Direction - Which way a line runs.
- Parameter
Kind - What kind of value a parameter takes.
- Picture
Mode - How a picture fits its box.
- Shape
Kind - Shape kinds.
- Text
Align - Horizontal text alignment.
- Value
- A value: what fields hold and expressions compute.
- Vertical
Align - Vertical text alignment.
Functions§
- decode_
picture - Decodes a PNG or JPEG from a
data:address or base64 text. Limits protect a server from a small file that expands into huge pixels. - format_
composite - Formats a composite string:
{0},{1:C2},{{and}}for braces. - format_
value - Formats
valuewith a .NET-style format specifier (C2,N0,dd/MM/yyyy,#,##0.00…). An empty specifier gives the plain text. - paint_
page - Paints
pagewith its top-left corner atorigin,scalelogical pixels per point. Draws the white paper with a soft shadow, then the content. - picture_
rect - Where an image goes in its control’s box.