xls

Version, currently 0.4.14 versions

github.com/mdwagner/xls.cr

Crystal bindings to libxls

2 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  xls:
    github: mdwagner/xls.cr
    version: ~> 0.4.1

Then run:

shards install

shard.yml

Crystal
>= 1.4.1
License
MIT
Author
Michael Wagner

Dependencies

This version declares no dependencies.

README

xls

Crystal bindings to libxls to read old Excel files (.xls)

Installation

  1. Install libxls

  2. Add the dependency to your shard.yml:

    dependencies:
      xls:
        github: mdwagner/xls.cr
        version: 0.4.1
  3. Run shards install

Usage

require "xls"

# Simple example of usage
Xls::Spreadsheet.open(Path.new("./example.xls")) do |s|
  skip_first_ws_puts = true

  s.worksheets.each do |ws|
    puts unless skip_first_ws_puts
    puts "Sheet: #{ws.name}"
    skip_first_row_puts = true

    ws.rows.each_with_index do |row, row_index|
      puts unless skip_first_row_puts
      puts "Row: #{row_index + 1}"

      row.cells.each_with_index do |cell, cell_index|
        puts "Cell: #{cell_index + 1}, Value: #{cell.value}"
      end

      skip_first_row_puts = false
    end

    skip_first_ws_puts = false
  end
end

Look at examples/ folder for more examples of different usage.

Contributors