Here are some easy instructions to get you up and running with the xlsxwriter module.
Xlsxwriter is a pure Lua module and doesn’t need a native compiler to install. However, it has a dependency on the ZipWriter module which does have binary dependencies.
These dependencies are handled automatically if you use the luarocks
or luadist
methods shown below.
The easiest way to install xlsxwriter
is with the luarocks utility:
$ sudo luarocks install xlsxwriter
Another easy “packaged” way of installing xlsxwriter
is with the luadist distribution:
$ sudo luadist install xlsxwriter
The xlsxwriter
source code and bug tracker is in the
xlsxwriter.lua repository on GitHub.
You can clone the repository and install from it as follows:
$ git clone https://github.com/jmcnamara/xlsxwriter.lua.git
$ cd xlsxwriter.lua
$ sudo luarocks make
# or
$ sudo luadist make
If the installation went correctly you can create a small sample program like the following to verify that the module works correctly:
local Workbook = require "xlsxwriter.workbook"
local workbook = Workbook:new("hello_world.xlsx")
local worksheet = workbook:add_worksheet()
worksheet:write("A1", "Hello world")
workbook:close()
Save this to a file called hello.lua
and run it as follows:
$ lua hello.lua
This will output a file called hello.xlsx
which should look something like
the following:
If you downloaded a tarball or cloned the repo, as shown above, you should also have a directory called examples with some sample applications that demonstrate different features of xlsxwriter.
The latest version of this document is hosted on Read The Docs. It is also available as a PDF.
Once you are happy that the module is installed and operational you can have a
look at the rest of the xlsxwriter
documentation. Tutorial 1: Create a simple XLSX file is a good
place to start.