Spreadsheet

Parse Spreadsheet files using Rustler and Calamine.

File formats supported are .xls, .xla, .xlsx, .xlsm, .xlam, xlsb and .ods.

Usage

To retrieve sheet names:

iex> Spreadsheet.sheet_names("test_file_1.xlsx")
{:ok, ["sheet1"]}

Or from a binary:

iex> Spreadsheet.sheet_names_from_bianry(File.read!("test_file_1.xlsx"))
{:ok, ["sheet1"]}

To retrieve rows:

iex> Spreadsheet.parse("test_file_1.xlsx")
{:ok, [["row1col1", "row1col2"], ["row2col1", "row2col2"]]}

Or from a binary:

iex> Spreadsheet.parse(File.read!("test_file_1.xlsx"))
{:ok, [["row1col1", "row1col2"], ["row2col1", "row2col2"]]}

Note that all dates will be retrieved as NaiveDateTime, and all numbers as Float.

For further documentation on how rows gets parsed, view the Calamine documentation:

https://docs.rs/calamine/latest/calamine/

Installation

If available in Hex, the package can be installed by adding xlsx to your list of dependencies in mix.exs:

def deps do
[
{:spreadsheet, "~> 0.1.0"}
]
end

By default you don't need Rust installed because the lib will try to download a precompiled NIF file. In case you want to force compilation set the application env in order to force the build:

config :rustler_precompiled, :force_build, spreadsheet: true

Alternatives

Development

Publishing a new version

As per instruction: https://hexdocs.pm/rustler_precompiled/precompilation_guide.html

Copyright (c) 2025 Wilhelm H Kirschbaum

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE.md file for more details.