Skip to main content

Crate ravenrs_report_xlsx

Crate ravenrs_report_xlsx 

Source
Expand description

XLSX and CSV export for RavenRS Reporting: lays a [Document] out on a grid of cells that follows the positions on the page, with real numbers and dates in the cells so a spreadsheet can sum and sort them.

Pages flow into one sheet: the page header prints once, at the top, and page footers are left out.

use ravenrs_report::{Band, Control, Report, ReportEngine};
use serde_json::json;

let report = Report::new("Sales").culture("pt-BR").detail(
    Band::new(18.0)
        .control(Control::field("[Customer]").at(0.0, 0.0, 200.0, 18.0))
        .control(Control::field("[Amount]").format("N2").at(200.0, 0.0, 80.0, 18.0)),
);
let document = ReportEngine::new().render(&report, &json!([{ "Customer": "Ana", "Amount": 10.5 }]));
assert_eq!(ravenrs_report_xlsx::to_csv(&document), "Ana;10,50\r\n");
let xlsx = ravenrs_report_xlsx::to_xlsx(&document)?;
assert!(xlsx.starts_with(b"PK"));

Enums§

XlsxExportError
Why a document could not be written as XLSX.

Functions§

to_csv
Writes document as CSV: one record per line of the report, one field per column of text, with the text as printed. Fields are separated by ; in cultures whose decimal separator is a comma and by , in the others, and records end in CRLF.
to_xlsx
Writes document as an XLSX workbook with one sheet.