lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2015-12-16 15:18 GMT+02:00 Geoff Smith <spammealot1@live.co.uk>:

> Just wondering if there are any libraries around to allow Lua to
> read/write data to Open Source Spreadsheets such as Libre Office,
> Google Spreadsheets, etc.

I get a couple of .xls files every week. Here is the relevant portion of
my program for reading them:

---
local filename = arg[1]
assert(filename,"Must supply a filename")
assert(filename:match"%.csv$" or filename:match"%.xls$",
   "Only .csv and .xls supported'")

if filename:match"xls$" then
   local csvname = filename:gsub("xls$","csv")
   local cmd = ("ssconvert %s %s > /dev/null 2> /dev/null"):
     format(filename,csvname)
   assert(os.execute(cmd))
   filename = csvname
end
---

The program "ssconvert" comes with gnumeric. It is by far the
best among several open-source commandline programs that
I have tried.

As Pierre has pointed out in a message that popped up
while I am writing this, once you have CSV, the rest is easy.