Hey 0/,
I just tagged odf v0.1.0, a pure-Crystal OASIS OpenDocument Format 1.3 shard built strictly on Crystal’s standard library (XML, Compress::Zip, Digest::CRC32) with zero runtime dependencies and zero C wrappers.
I needed self-contained static binaries that could generate and parse real spreadsheets with live formulas and proper styling without shelling out to Python or LibreOffice, so I built odf from the ground up.
What’s in v0.1.0
.odsWriter (Odf::Spreadsheet::Workbook): Multi-sheet workbooks, typed cells (text,integer,float,currency,percent,boolean,date,time), live OpenFormulaof:=expressions, cell merges, frozen panes, autofilters, and reusable styles/number formats.- Hardened
.odsReader (Odf::Spreadsheet::Reader):NONETXXE-safe XML parsing, streaming Zip-bomb byte quotas, and bounded repeat-cell expansion. - Extensible Core (
Odf::Document):Odf::PackageandOdf::Stylesare document-agnostic, so adding.odt,.odp, and.odgsupport does not require touching the container engine.
Quick Taste
require "odf"
workbook = Odf::Spreadsheet::Workbook.new do |book|
book.currency_style("usd", symbol: "$", decimals: 2, negative_red: true)
book.sheet("BOM") do |sheet|
sheet.freeze(rows: 1)
sheet.header_row(["Qty", "Item", "Unit Price", "Total"])
sheet.row do |row|
row.integer(4)
row.text("NVMe OSD Node")
row.currency(12_500.00, style: "usd")
row.formula("=[.A2]*[.C2]", cached: 50_000.00, style: "usd")
end
end
end
workbook.save("bom.ods")
doc = Odf::Spreadsheet::Reader.open("bom.ods")
puts doc.sheet("BOM")[1][3].as_f # => 50000.0
Links
- Repository: René Bon Ćirić (Rénich) / odf · GitLab
- Docs & Specs: odf Documentation — odf v0.1.0 Documentation
- API Reference: odf v0.1.0
If anyone is interested in tackling .odt, .odp, or .odg modules on top of Odf::Document, contributions and feedback are very welcome!