module XLSX class Workbook attr_accessor :sheets # an array of all the sheets in this workbook. attr_accessor :strings # :nodoc: # create a new work book def initialize @sheets = Array.new @strings = Array.new end # Add a new sheet with name. def add_sheet(name) sheet = Sheet.new @sheets.push(sheet) sheet.id = @sheets.size sheet.name = name sheet.hash = Digest::SHA1.hexdigest("#{name}--#{sheet.id}") sheet.workbook = self yield(sheet) if block_given? sheet end # Get the data. def build ::XLSX::Formatter.build(self) end # Write the data to an .xlsx file def dump(path=nil) ::XLSX::Formatter.dump(self, path) end def register_string(string) # :nodoc: index = @strings.index(string) if index.nil? index = @strings.size @strings.push string end index end end end