Xlsxir
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.
Installation
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.5"} ]
endOr, you can directly reference the GitHub repo:
def deps do
[ {:xlsxir, github: "kennellroxco/xlsxir"} ]
endBasic Usage
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:
paththe path of the file to be parsed instringformatindexis the position of the worksheet you wish to parse, starting with0optionis 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 documentation for more detailed examples.
Considerations
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.
Planned Development
- Performance improvement for larger files
- Adding time support for dates (i.e. {{YYYY, MM, DD}, {h, m, s}})
- Export functionality to .xlsx file type with formatting options
Contributing
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.
Bug Reporting
Please report any bugs or request future enhancements via the Issues page.