Skip to content

agendor/agendor-xls-reader

Repository files navigation

Agendor FastXlsxReader

Agendor FastXlsxReader is a simple high performance GEM for reading Microsoft Excel files with low footprint. Uses XLSX/IO as the base of the native extension.

Dependencies

FastXlsxReader needs some native dependencies to compile the extension, they are:

  • A C compiler;
  • GNU Make;
  • Minizip;

Installation

Before installing the GEM, install the native dependencies on your operating system.

Debian based

apt-get install -y libminizip-dev build-essential

RHEL (Red Hat/CentOS/Alma Linux/Rocky Linux/Oracle Linux)

yum groupinstall 'Development Tools'
yum install minizip-devel

OpenSuse

zypper install -t pattern devel_basis
zypper install minizip-devel

Alpine

apk add alpine-sdk
apk add minizip-dev

Now just reference the library in your Gemfile:

gem 'fast_xlsx_reader'

And then execute:

bundle

Or install it yourself as:

gem install fast_xlsx_reader

Usage

FastXlsxReader has only one class (Reader) with only three methods:

Constructor

Receives the path of the file to be opened. If the file does not exist, it will throw a "TypeError" exception.

reader = FastXlsxReader::Reader.new("my_spreadsheet.xlsx")

each

The each method scans the first sheet of the file and calls the iteration block for each row. For each line, an array of strings is passed to the block with all cell values.

reader.each do |row|
  puts "Cells: #{row.join(", ")}"
end

file_name

Method that returns the name of the file that was passed in the constructor. It's just a getter :-)

Full example

reader = FastXlsxReader::Reader.new("my_spreadsheet.xlsx")
reader.each do |row|
  puts "Cells: #{row.join(", ")}"
end

And that's it.

Development

After checking out the repo, run docker-compose build dev to build a base image with all dependencies.

To run tests, use docker-compose run tests. To run tests with coverage, use docker-compose run coverage. To build the GEM use docker-compose run build.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/agendor/agendor-xls-reader. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the FastXlsxReader project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages