#[non_exhaustive]pub struct Workbook { /* private fields */ }Expand description
An Excel workbook with several sheets, each one a grid’s export of a
query (needs renox’s xlsx feature; without it Workbook::sheet
answers 400, like the single-sheet export). Sheets appear in the order
they are added; each uses the grid’s columns that show by default on
wide screens, with the same headings, number formats and frozen columns
as Grid::export_as.
use renox::grid::{Column, Grid, GridRequest, Workbook};
// GET /reports/summary.xlsx
async fn summary(request: GridRequest) -> Result<Response> {
let sales = Grid::new("sales").column(Column::money("total", "Total"));
let refunds = Grid::new("refunds").column(Column::money("amount", "Amount"));
Workbook::new("summary")
.sheet("Sales", &sales, Sale::query().order_by("id"), &request).await?
.sheet("Refunds", &refunds, Refund::query().order_by("id"), &request).await?
.into_response()
}Implementations§
Source§impl Workbook
impl Workbook
Sourcepub async fn sheet<M: Model + Serialize>(
self,
title: &str,
grid: &Grid,
query: Query<M>,
request: &GridRequest,
) -> Result<Self>
pub async fn sheet<M: Model + Serialize>( self, title: &str, grid: &Grid, query: Query<M>, request: &GridRequest, ) -> Result<Self>
Adds a sheet called title (at most 31 characters, none of
[]:*?/\, unique in the workbook) with every row query
matches, up to MAX_EXPORT_ROWS. The request’s filters and the
user’s column choices don’t apply (as in Grid::export_as).
Sourcepub fn into_response(self) -> Result<Response>
pub fn into_response(self) -> Result<Response>
The .xlsx download of the sheets added so far.
Auto Trait Implementations§
impl !RefUnwindSafe for Workbook
impl !UnwindSafe for Workbook
impl Freeze for Workbook
impl Send for Workbook
impl Sync for Workbook
impl Unpin for Workbook
impl UnsafeUnpin for Workbook
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more