[ANN] odf v0.1.0: Pure-Crystal OASIS ODF 1.3 .ods reader and writer, zero dependencies

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

  • .ods Writer (Odf::Spreadsheet::Workbook): Multi-sheet workbooks, typed cells (text, integer, float, currency, percent, boolean, date, time), live OpenFormula of:= expressions, cell merges, frozen panes, autofilters, and reusable styles/number formats.
  • Hardened .ods Reader (Odf::Spreadsheet::Reader): NONET XXE-safe XML parsing, streaming Zip-bomb byte quotas, and bounded repeat-cell expansion.
  • Extensible Core (Odf::Document): Odf::Package and Odf::Styles are document-agnostic, so adding .odt, .odp, and .odg support 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

If anyone is interested in tackling .odt, .odp, or .odg modules on top of Odf::Document, contributions and feedback are very welcome!

4 Likes