Skip to main content

Report

Struct Report 

Source
pub struct Report {
Show 18 fields pub name: String, pub page: PageSettings, pub culture: String, pub data_sources: Vec<DataSource>, pub data_source: Option<String>, pub data_member: Option<String>, pub filter: Option<String>, pub sort: Vec<SortField>, pub parameters: Vec<Parameter>, pub calculated_fields: Vec<CalculatedField>, pub styles: BTreeMap<String, Style>, pub report_header: Option<Band>, pub page_header: Option<Band>, pub groups: Vec<Group>, pub detail: Band, pub detail_reports: Vec<DetailReport>, pub report_footer: Option<Band>, pub page_footer: Option<Band>,
}
Expand description

A banded report definition.

use ravenrs_report::{Band, Control, Report};

let report = Report::new("Customers")
    .page_header(Band::new(24.0).control(Control::label("Name").at(0.0, 0.0, 200.0, 20.0)))
    .detail(Band::new(20.0).control(Control::field("[Name]").at(0.0, 0.0, 200.0, 20.0)));
let json = report.to_json();
assert_eq!(ravenrs_report::Report::from_json(&json).expect("round trip"), report);

Fields§

§name: String

The report’s name, also the document title.

§page: PageSettings

Paper size and margins.

§culture: String

Culture for numbers and dates, such as pt-BR or en-US.

§data_sources: Vec<DataSource>

Where the data comes from, saved with the layout. The engine renders whatever data it is given; designers and the report server load it from here.

§data_source: Option<String>

The data source that feeds the report (the first one when unset).

§data_member: Option<String>

Path to the rows in the data (orders, report.lines). Without it, an array of data is the rows and an object is a single row.

§filter: Option<String>

Rows for which this expression is false are left out.

§sort: Vec<SortField>

Sorting of detail rows within their groups.

§parameters: Vec<Parameter>

Values the user supplies when running the report (?Name in expressions).

§calculated_fields: Vec<CalculatedField>

Fields computed from other fields, usable like data fields.

§styles: BTreeMap<String, Style>

Named styles that controls refer to.

§report_header: Option<Band>

Printed once, at the top of the first page.

§page_header: Option<Band>

Printed at the top of every page.

§groups: Vec<Group>

Groups, outermost first.

§detail: Band

Printed once per row.

§detail_reports: Vec<DetailReport>

Nested reports printed after each row’s detail (master-detail).

§report_footer: Option<Band>

Printed once, after the last row.

§page_footer: Option<Band>

Printed at the bottom of every page.

Implementations§

Source§

impl Report

Source

pub fn new(name: impl Into<String>) -> Self

An empty report on A4 paper, in US English.

Source

pub fn from_json(json: &str) -> Result<Self, Error>

Reads a report from JSON.

Source

pub fn to_json(&self) -> String

The report as indented JSON.

Source

pub fn page(self, page: PageSettings) -> Self

Sets the paper.

Source

pub fn data_source(self, source: DataSource) -> Self

Adds a data source and makes it the report’s source.

Source

pub fn embedded_data(&self) -> Option<&Value>

The data of the report’s source when it is stored in the layout.

Source

pub fn culture(self, culture: &str) -> Self

Sets the culture (pt-BR, en-US).

Source

pub fn data_member(self, path: &str) -> Self

Sets the path to the rows in the data.

Source

pub fn filter(self, expression: &str) -> Self

Keeps only rows where expression is true.

Source

pub fn sort_by(self, expression: &str, descending: bool) -> Self

Adds a sort key.

Source

pub fn parameter(self, name: &str, kind: ParameterKind, default: Value) -> Self

Adds a parameter with a default value.

Source

pub fn parameter_label(self, label: &str) -> Self

Sets what the user is asked for the parameter added last.

Source

pub fn calculated(self, name: &str, expression: &str) -> Self

Adds a calculated field.

Source

pub fn style(self, name: &str, style: Style) -> Self

Adds a named style.

Source

pub fn report_header(self, band: Band) -> Self

Sets the report header.

Source

pub fn page_header(self, band: Band) -> Self

Sets the page header.

Source

pub fn group(self, group: Group) -> Self

Adds a group level (outermost first).

Source

pub fn detail(self, band: Band) -> Self

Sets the detail band.

Source

pub fn detail_report(self, detail: DetailReport) -> Self

Adds a master-detail report.

Sets the report footer.

Sets the page footer.

Trait Implementations§

Source§

impl Clone for Report

Source§

fn clone(&self) -> Report

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Report

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Report

Source§

fn default() -> Report

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Report
where Report: Default,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Report

Source§

fn eq(&self, other: &Report) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Report

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Report

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Brush for T
where T: Clone + PartialEq + Default + Debug,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.