Xlsxir is an Elixir library that parses Microsoft Excel worksheets (currently only
.xlsx
format) and returns the data in either a list
or a map
.
You can add Xlsxir as a dependancy to your Elixir project via the Hex package manager by adding the following to your mix.exs
file:
def deps do
[ {:xlsxir, "~> 0.0.1"} ]
end
Or, you can directly reference the GitHub repo:
def deps do
[ {:xlsxir, github: "kennellroxco/xlsxir"} ]
end
Xlsxir can parse an excel file and return the data in one of two ways depending on the option chosen. The main function takes 2 or 3 arguments:
Xlsxir.extract(path, index, option \\ :rows)
Argument descriptions:
path
the path of the file to be parsed instring
formatindex
is the position of the worksheet you wish to parse, starting with0
option
is the method in which you want the data returned
Options:
:rows
- a list of row value lists (default) - i.e.[[row_1_values], [row_2_values], ...]
:cells
- a map of cell/value pairs - i.e.%{ A1: value_of_cell, B1: value_of_cell, ...}
Refer to Xlsxir library documentation for more detailed examples.
Strings will be returned as type string
, resulting values for functions from within Excel are returned as type string
, integer
or float
depending on the type of the resulting value, data formatted as a number in Excel will be returned as type integer
or float
, and Excel date formatted values will be returned in Erlang :calendar.date()
type format (i.e. {year, month, day}
). Excel does not support dates prior to 1/1/1900.
Contributions are encouraged. Feel free to fork the repo, add your code along with appropriate tests and documentation (ensuring all existing tests continue to pass) and submit a pull request.
Please report any bugs or request future enhancements via the Issues page.