ravenrs_report/lib.rs
1//! RavenRS Reporting: banded reports, defined as data, paginated into
2//! documents that the viewer shows and the exporters write.
3//!
4//! * [`Report`] is the definition. It covers the page, bands, groups, controls,
5//! styles, parameters, calculated fields and data sources, and is saved as
6//! JSON or built in code.
7//! * [`ReportEngine`] binds data to it and produces a [`Document`]: pages of
8//! positioned text, lines and shapes, in points.
9//! * Expressions come from [`ravenrs_criteria`]: `[Price] * [Quantity]`, `Sum([Total])`,
10//! `Iif(...)`, `FormatString('{0:C2}', ...)`.
11//!
12//! ```
13//! use ravenrs_report::{Band, Control, Group, Report, ReportEngine, Style};
14//! use serde_json::json;
15//!
16//! let report = Report::new("Sales")
17//! .culture("pt-BR")
18//! .group(
19//! Group::new("[Region]")
20//! .header(Band::new(22.0).control(Control::field("[Region]").at(0.0, 0.0, 300.0, 22.0).style(Style::new().bold())))
21//! .footer(Band::new(20.0).control(Control::field("Sum([Amount])").format("C2").at(0.0, 0.0, 300.0, 20.0))),
22//! )
23//! .detail(Band::new(18.0).control(Control::field("[Customer]").at(12.0, 0.0, 300.0, 18.0)));
24//! let data = json!([
25//! { "Region": "Sul", "Customer": "Ana", "Amount": 10.5 },
26//! { "Region": "Norte", "Customer": "Bruno", "Amount": 20 },
27//! { "Region": "Sul", "Customer": "Carla", "Amount": 4.5 },
28//! ]);
29//! let doc = ReportEngine::new().render(&report, &data);
30//! assert_eq!(doc.page_text(0), ["Norte", "Bruno", "R$\u{a0}20,00", "Sul", "Ana", "Carla", "R$\u{a0}15,00"]);
31//! ```
32
33pub mod base64;
34mod document;
35mod engine;
36mod model;
37mod paint;
38pub mod samples;
39pub mod wizard;
40
41pub use document::{Document, DocumentImage, ImageFormat, Item, Page, PlacedLine, TextBlock};
42pub use engine::{RenderOptions, ReportEngine, decode_picture, picture_rect};
43pub use model::*;
44pub use paint::paint_page;
45pub use ravenrs_criteria as criteria;
46pub use ravenrs_criteria::{Criteria, Culture, DateTime, ParseError, Value, format_composite, format_value};
47pub use ravenrs_graphics::{barcode, chart, vector};