Sha256: 397fd7f353593576279736fdd42b4926b4397228ef2d43998a101292dcd02d39

Contents?: true

Size: 674 Bytes

Versions: 10

Compression:

Stored size: 674 Bytes

Contents

module Roo
  module Formatters
    module Matrix
      # returns a matrix object from the whole sheet or a rectangular area of a sheet
      def to_matrix(from_row = nil, from_column = nil, to_row = nil, to_column = nil, sheet = default_sheet)
        require 'matrix'

        return ::Matrix.empty unless first_row

        from_row ||= first_row(sheet)
        to_row ||= last_row(sheet)
        from_column ||= first_column(sheet)
        to_column ||= last_column(sheet)

        ::Matrix.rows(from_row.upto(to_row).map do |row|
          from_column.upto(to_column).map do |col|
            cell(row, col, sheet)
          end
        end)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
roo-2.10.1 lib/roo/formatters/matrix.rb
roo-2.10.0 lib/roo/formatters/matrix.rb
roo-2.9.0 lib/roo/formatters/matrix.rb
ruh-roo-3.0.1 lib/roo/formatters/matrix.rb
roo-2.8.3 lib/roo/formatters/matrix.rb
roo-2.8.2 lib/roo/formatters/matrix.rb
roo-2.8.1 lib/roo/formatters/matrix.rb
roo-2.8.0 lib/roo/formatters/matrix.rb
roo-2.7.1 lib/roo/formatters/matrix.rb
roo-2.7.0 lib/roo/formatters/matrix.rb