class Saxlsx::Workbook

Constants

DATE_SYSTEM_1900
DATE_SYSTEM_1904

Attributes

auto_format[R]
date1904[RW]

Public Class Methods

new(filename, auto_format: true) click to toggle source
# File lib/saxlsx/workbook.rb, line 19
def initialize(filename, auto_format: true)
  @file_system = FileSystem.new filename
  @auto_format = auto_format
end
open(filename, **kw_args) { |workbook| ... } click to toggle source
# File lib/saxlsx/workbook.rb, line 10
def self.open(filename, **kw_args)
  begin
    workbook = new(filename, **kw_args)
    yield workbook
  ensure
    workbook.close if workbook
  end
end

Public Instance Methods

base_date() click to toggle source
# File lib/saxlsx/workbook.rb, line 45
def base_date
  @base_date ||= date1904 ? DATE_SYSTEM_1904 : DATE_SYSTEM_1900
end
close() click to toggle source
# File lib/saxlsx/workbook.rb, line 24
def close
  @file_system.close
end
number_formats() click to toggle source
# File lib/saxlsx/workbook.rb, line 41
def number_formats
  @number_formats ||= StyleCollection.new(@file_system).to_a
end
shared_strings() click to toggle source
# File lib/saxlsx/workbook.rb, line 37
def shared_strings
  @shared_strings ||= SharedStringCollection.new(@file_system).to_a
end
sheet_names() click to toggle source
# File lib/saxlsx/workbook.rb, line 33
def sheet_names
  sheets.map(&:name)
end
sheets(name=nil) click to toggle source
# File lib/saxlsx/workbook.rb, line 28
def sheets(name=nil)
  @sheets ||= SheetCollection.new(@file_system, self).to_a
  name.nil? ? @sheets : @sheets.detect { |s| s.name == name }
end
to_csv(path) click to toggle source
# File lib/saxlsx/workbook.rb, line 49
def to_csv(path)
  sheets.each { |s| s.to_csv path }
end