Expand description
Univer spreadsheets for Autumn, with Maud + htmx ergonomics.
Add UniverPlugin to the app. Put univer_stylesheet() and
univer_script() in the page <head>. Render a Spreadsheet:
use autumn_plugin_univer::{
Cell, Sheet, Spreadsheet, UniverPlugin, Workbook, univer_script, univer_stylesheet,
};
use autumn_web::prelude::*;
#[get("/")]
async fn index() -> Markup {
let workbook = Workbook::builder("budget", "Budget")
.sheet(
Sheet::new("q1", "Q1")
.with_row(0, [Cell::text("Rent"), Cell::number(1200.0)])
.with_cell(1, 1, Cell::formula("=B1*12")),
)
.build()
.unwrap_or_else(|_| Workbook::empty("budget"));
html! {
html {
head { (univer_stylesheet()) (univer_script()) }
body {
(Spreadsheet::new("budget").workbook(&workbook).save_url("/budget"))
}
}
}
}
autumn_web::app()
.plugin(UniverPlugin::new())
.routes(routes![index])
.run()
.await;The plugin vendors Univer 1.0 (Apache-2.0) as one
code-split ES module bundle. No npm, no bundler and no CDN in the host
app. The bundle is the UNIVER_ASSETS Autumn plugin asset bundle. It
serves from memory under /static/_plugins/univer/ with content-hashed,
immutable URLs and SRI hashes.
Read a saved sheet back with the WorkbookSnapshot extractor. It
validates the data against the Workbook invariants and Limits.
§Limits
- Only the open-source sheets core preset is in. Univer Pro features (XLSX import and export, collaboration, charts) are not.
- Each plugin release pins one Univer version (see
UNIVER_VERSION). - Without JavaScript, the page shows a
<noscript>notice.
Structs§
- Cell
- One cell (Univer
ICellData). - CellRef
- A cell position. Both parts start at zero:
A1is(0, 0). - Limits
- Size limits for
Workbook::validate_with. - Sheet
- One sheet (Univer
IWorksheetData). - SheetId
- The id of a
Sheetin a workbook. - Spreadsheet
- The mount markup for one Univer workbook.
- Univer
Plugin - Installs the Univer assets in an Autumn app.
- Unknown
Locale - The error for a locale code that is not in this build.
- Workbook
- A workbook (Univer
IWorkbookData). - Workbook
Builder - Builds a valid
Workbook. SeeWorkbook::builder. - Workbook
Id - The id of a
Workbook. - Workbook
Snapshot - A request body that holds a valid
Workbook.
Enums§
- Cell
Type - The cell type hint (Univer
t,CellValueType). - Cell
Value - A cell value (Univer
v). - Locale
- The UI language of a
Spreadsheet. - Workbook
Error - Why a workbook is not valid. See the module docs for the invariants.
Constants§
- ASSETS_
NAMESPACE - URL namespace of the bundle. Files serve under
/static/_plugins/univer/. - PLUGIN_
NAME - The plugin name in Autumn diagnostics.
- UNIVER_
VERSION - The Univer version in
assets/dist/.
Statics§
- UNIVER_
ASSETS - The plugin asset bundle.
Functions§
- save_
button - Renders a button that saves the spreadsheet with this DOM id.
- univer_
script - Renders the
<script>tags that load Univer and the mount script. - univer_
stylesheet - Renders the
<link>tags for the Univer and plugin stylesheets.