GithubHelp home page GithubHelp logo

xlsx_reader's Introduction

XlsxReader logo

XlsxReader

Build status

An XLSX reader in Elixir.

Features:

  • Accepts XLSX data located on the file system or in memory
  • Automatic type conversions (numbers, date & times, booleans)
  • Optional support for arbitrary precision decimal numbers
  • Straightforward architecture: no ETS tables, no race-conditions, no manual resource management

The docs can be found at https://hexdocs.pm/xlsx_reader.

Installation

Add xlsx_reader as a dependency in your mix.exs:

def deps do
  [
    {:xlsx_reader, "~> 0.8.0"}
  ]
end

Run mix deps.get in your shell to fetch and compile XlsxReader.

Examples

Loading from the file system

{:ok, package} = XlsxReader.open("test.xlsx")

XlsxReader.sheet_names(package)
# ["Sheet 1", "Sheet 2", "Sheet 3"]

{:ok, rows} = XlsxReader.sheet(package, "Sheet 1")
# [
#   ["Date", "Temperature"], 
#   [~D[2019-11-01], 8.4], 
#   [~D[2019-11-02], 7.5], 
#   ...
# ]

Loading from memory

blob = File.read!("test.xlsx")

{:ok, package} = XlsxReader.open(blob, source: :binary)

Loading all sheets at once

{:ok, sheets} = XlsxReader.sheets(package)
# [
#   {"Sheet 1", [["Date", "Temperature"], ...]}, 
#   {"Sheet 2", [...]}, 
#   ...
# ]

Loading sheets selectively

{:ok, sheets} = XlsxReader.sheets(package, only: ["Parameters", ~r/Sheet \d+/], except: ["Sheet 2"])
# [
#   {"Parameters", [...]}, 
#   {"Sheet 1", [...]}, 
#   {"Sheet 3", [...]}, 
#   {"Sheet 4", [...]}, 
#   ...
# ]

Loading all sheets at once concurrently

{:ok, sheets} = XlsxReader.async_sheets(package)
# [
#   {"Sheet 1", [["Date", "Temperature"], ...]}, 
#   {"Sheet 2", [...]}, 
#   ...
# ]

Using arbitrary precision numbers

{:ok, rows} = XlsxReader.sheet(package, "Sheet 1", number_type: Decimal)
# [
#   ["Date", "Temperature"], 
#   [~D[2019-11-01], %Decimal{coef: 84, exp: -1, sign: 1}], 
#   [~D[2019-11-02], %Decimal{coef: 75, exp: -1, sign: 1}], 
#   ...
# ]

Access cell formulas

{:ok, rows} = XlsxReader.sheet(package, "Sheet 1", cell_data_format: :cell)
# [
#   [%Cell{value: 1234.0, formula: "SUM(B1, B10)", ref: "A1"}, ...], 
#   ...
# ]

Development

Benchmarking

  1. mix run benchmark/init.exs to create the benchmarking dataset
  2. mix run benchmark/run.exs to run the Benchee suite

Contributors

In order of appearance:

License

Copyright 2020 Xavier Defrang

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

xlsx_reader's People

Contributors

xavier avatar 03juan avatar dharness avatar darraghenright avatar evaldobratti avatar kianmeng avatar patrykwozinski avatar zachliss avatar paranojik avatar

Stargazers

Leandro Camargo avatar  avatar Wilhelm Kirschbaum avatar Henrique Manoel de Freitas Santos avatar Douglas Liebl avatar Daniel Kaiser avatar Carl Gleisner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.