Skip to main content

Crate ravenrs_report

Crate ravenrs_report 

Source
Expand description

RavenRS Reporting: banded reports, defined as data, paginated into documents that the viewer shows and the exporters write.

  • Report is 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.
  • ReportEngine binds data to it and produces a Document: 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.
CalculatedField
A field computed from an expression.
Chart
A chart.
ChartSeries
A chart’s series.
CheckBox
A check box.
Control
A printable element of a band.
Culture
Number, currency and date conventions of a language and region.
DataSource
A named source of report data, stored with the layout.
DateTime
A calendar date with an optional time of day, without a time zone.
DetailReport
Master-detail: a nested list printed after each row of the report.
Document
A paginated document.
DocumentImage
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.
FormattingRule
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.
LinkLabel
A label that is also a link.
Page
One page.
PageSettings
Paper size and margins, in points.
Panel
A container of controls.
Parameter
A value supplied when the report runs.
ParseError
A syntax error, with the byte offset where it was found.
Picture
A picture.
PlacedLine
A line of text at its position on the page.
RenderOptions
Settings for one run of a report.
Report
A banded report definition.
ReportEngine
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.
SortField
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.
TableCell
A table cell.
TableRow
A table row; its height grows to its tallest cell.
TextBlock
Text already broken into lines and positioned.

Enums§

ControlKind
The kinds of controls.
Criteria
A parsed expression or filter.
DataSourceKind
How a data source obtains its data.
ImageFormat
The file format of a DocumentImage.
Item
A printed primitive.
LineDirection
Which way a line runs.
ParameterKind
What kind of value a parameter takes.
PictureMode
How a picture fits its box.
ShapeKind
Shape kinds.
TextAlign
Horizontal text alignment.
Value
A value: what fields hold and expressions compute.
VerticalAlign
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 value with a .NET-style format specifier (C2, N0, dd/MM/yyyy, #,##0.00…). An empty specifier gives the plain text.
paint_page
Paints page with its top-left corner at origin, scale logical 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.