No description
Find a file
Dario Lah 599a74f9c7
Merge pull request #2 from Toma400/master
Changed `zip` dependency to `zippy`
2024-11-03 11:41:00 +01:00
src Small fix 2024-11-01 20:32:21 +01:00
tests Fix multiline text in a cell 2021-11-14 15:14:32 +01:00
odsreader.nimble Changed dependencies from zip to zippy and also put it as required for better Nimble download handling (+ changed version to 0.4.0) 2024-11-01 20:24:38 +01:00
README.md Fix multiline text in a cell 2021-11-14 15:14:32 +01:00

odsreader - library for reading OpenDocument Spreadsheet (.ods) files

QuickStart

demo.nim

import odsreader
import strformat
import std/tables

proc mainProc =
  let ods_filename = "tests/test.ods"
  echo &"Loading first sheet from {ods_filename}"
  let doc = loadOds(filename)

  echo doc.getSheetNames()
  echo doc["Sheet1"].getColumnNames()

  # Sheet iterator
  for row in doc.["Sheet1"]:
    # row column access
    echo row["first"]

if isMainModule:
  mainProc()

Or just use nested sequences and tables...

demoseq.nim

import odsreader
import strformat
import std/tables

proc mainProc =
  let ods_filename = "tests/test.ods"
  echo &"Loading first sheet from {ods_filename}"
  let odsFirstSheet = loadOdsAsSeq(ods_filename)
  echo odsFirstSheet

  # load sheet by name
  echo &"Loading sheet Sheet2 from {ods_filename}"
  let odsSheet2 = loadOdsAsSeq(ods_filename, "Sheet2")
  echo odsSheet2

  # load all sheets as table
  echo &"Loading all sheets from {ods_filename} as table"
  let odsTable = loadOdsAsTable(ods_filename)
  echo odsTable

if isMainModule:
  mainProc()