Sha256: f9bdb2580c994cde385068453e68d2259ea4d80329e969d23b7f1fdf171990bf

Contents?: true

Size: 579 Bytes

Versions: 6

Compression:

Stored size: 579 Bytes

Contents

# frozen_string_literal: true
module Saxlsx
  class Sheet

    attr_reader :name

    def initialize(name, index, file_system, workbook)
      @name = name
      @index = index
      @file_system = file_system
      @workbook = workbook
    end

    def rows
      @rows ||= RowsCollection.new(@index, @file_system, @workbook)
    end

    def to_csv(path)
      FileUtils.mkpath path unless Dir.exists? path
      File.open("#{path}/#{name}.csv", 'w') do |f|
        rows.each do |row|
          f.puts row.map{|c| "\"#{c}\""}.join(',')
        end
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
saxlsx-1.11.0 lib/saxlsx/sheet.rb
saxlsx-1.10.0 lib/saxlsx/sheet.rb
saxlsx-1.9.0 lib/saxlsx/sheet.rb
saxlsx-1.8.0 lib/saxlsx/sheet.rb
saxlsx-1.7.1 lib/saxlsx/sheet.rb
saxlsx-1.7.0 lib/saxlsx/sheet.rb