GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dmk/fastsheet: FastSheet is the fastest XLSX file parser for Ruby (at the time of release). It leverages a Rust library for high-performance parsing, making it significantly faster than other available solutions.

BranchesTags
Open more actions menu

Latest commit

 

History

42 Commits
42 Commits

Folders and files

NameName
Last commit message
Last commit date
.cursor/rules
.cursor/rules
 
 
.github/workflows
.github/workflows
 
 
.vscode
.vscode
 
 
bin
bin
 
 
examples/xlsx
examples/xlsx
 
 
ext/fastsheet
ext/fastsheet
 
 
lib
lib
 
 
spec
spec
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.rspec
.rspec
 
 
.rubocop.yml
.rubocop.yml
 
 
.ruby-version
.ruby-version
 
 
Gemfile
Gemfile
 
 
Gemfile.lock
Gemfile.lock
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
extconf.rb
extconf.rb
 
 
fastsheet.gemspec
fastsheet.gemspec
 
 

Repository files navigation

Fastsheet

Fastest ruby gem for reading Excel documents.

Installation

You need Rust 1.88 or newer to build this gem. Tested with Ruby 3.2+.

Add this line to your application's Gemfile:

gem 'fastsheet'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fastsheet

Usage

Basic Usage

Open a sheet:

require 'fastsheet'

sheet = Fastsheet::Sheet.new('path/to/sheet.xlsx')

# number of columns
sheet.width

# number of rows
sheet.height

Get rows or columns:

sheet.rows
sheet.row(42)
sheet.column(1)

Iterators (returns enumerator if no block given):

sheet.each_row { |r| ... }
sheet.each_column { |c| ... }
sheet.each_column.to_a # materialize columns if you need them all

Sheet Selection

Read specific sheets from multi-sheet workbooks:

# Read sheet by name
sheet = Fastsheet::Sheet.new('path/to/workbook.xlsx', sheet: 'Data')

# Read sheet by index (0-based)
sheet = Fastsheet::Sheet.new('path/to/workbook.xlsx', sheet: 1)

# Get information about available sheets
sheet_names = Fastsheet::Sheet.sheet_names('path/to/workbook.xlsx')
# => ['Sheet1', 'Data', 'Summary']

sheet_count = Fastsheet::Sheet.sheet_count('path/to/workbook.xlsx')
# => 3

# Access current sheet information
sheet.sheet_name   # => 'Data'
sheet.sheet_index  # => 1

Headers and Options

All existing options work with sheet selection:

# Read specific sheet with header row
sheet = Fastsheet::Sheet.new('path/to/workbook.xlsx',
                             sheet: 'Data',
                             header: true)

sheet.header  # => ['Name', 'Age', 'City']
sheet.rows    # => [['Alice', 30, 'NYC'], ['Bob', 25, 'LA']]

Error Handling

The library provides specific exceptions for invalid sheet selections:

begin
  sheet = Fastsheet::Sheet.new('file.xlsx', sheet: 'NonExistent')
rescue Fastsheet::SheetNotFoundError => e
  puts "Sheet not found: #{e.message}"
end

begin
  sheet = Fastsheet::Sheet.new('file.xlsx', sheet: 99)
rescue Fastsheet::SheetIndexError => e
  puts "Invalid sheet index: #{e.message}"
end

Backward Compatibility

Existing code continues to work unchanged. When no sheet is specified, the first sheet is read by default:

# These are equivalent:
sheet1 = Fastsheet::Sheet.new('file.xlsx')
sheet2 = Fastsheet::Sheet.new('file.xlsx', sheet: 0)

Data Types

The library automatically converts Excel data types:

  • Numbers (integers and floats)
  • Strings (with whitespace trimming)
  • Booleans (true/false)
  • Empty cells (as nil)
  • Error cells (as nil)
  • Numeric Excel dates and times (as Ruby Time, interpreted as UTC instants; display follows the local timezone)
  • Numeric Excel durations such as [h]:mm:ss (as seconds, Float)
  • ISO dates and durations (as strings)

Unrepresentable numeric dates return nil. Formula cells expose cached values when present; formula text and recalculation are not exposed.

Sheet selectors are type-sensitive: integers select zero-based indexes, while strings select exact sheet names, including numeric names such as "123". Invalid selector types raise TypeError; missing or unreadable files raise IOError.

Value Conversion Options

Conversion options apply to all cells, including the extracted header. Defaults preserve the behavior described above.

Option Default Alternatives
dates :time :date returns Ruby Date; :excel_serial returns the original numeric date/time serial
timezone :local :utc returns Time objects displayed in UTC
errors :nil :string returns Excel error text such as "#DIV/0!" or "#N/A"
strip_strings true false preserves string whitespace supplied by the parser
blank_strings :nil :preserve keeps empty strings after optional trimming
sheet = Fastsheet::Sheet.new('workbook.xlsx',
                             dates: :date,
                             errors: :string,
                             strip_strings: false,
                             blank_strings: :preserve)

Excel numeric dates contain no timezone. timezone controls display only: both settings interpret the spreadsheet clock as UTC. dates: :date uses that clock's calendar day, regardless of the local timezone, and discards the time of day. This explicitly converts all numeric date/time cells; it does not infer which cells are date-only. timezone has no effect with :date or :excel_serial.

Numeric durations remain seconds under every date policy. ISO date and duration strings remain strings. Raw serial mode preserves otherwise unrepresentable dates and Excel's fictional leap-day serial 60; Time and Date conversion map it to February 28, 1900. A raw serial must be interpreted using its workbook's 1900 or 1904 date system.

With strip_strings: false, whitespace-only strings remain strings even when blank_strings: :nil. Missing cells always remain nil. Error text in :string mode has the same Ruby type as a literal string containing that text. Invalid conversion option values raise ArgumentError before the file is opened.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dkkoval/fastsheet.

License

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

About

FastSheet is the fastest XLSX file parser for Ruby (at the time of release). It leverages a Rust library for high-performance parsing, making it significantly faster than other available solutions.

Topics

excelgemrubyrustspreadsheetsxlsx

Resources

Readme
MIT license
Activity

Stars

29 stars

Watchers

0 watching

Forks

7 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.