Class: XLSX::Workbook
- Inherits:
-
Object
- Object
- XLSX::Workbook
- Defined in:
- lib/xlsx/workbook.rb
Instance Attribute Summary collapse
-
#sheets ⇒ Object
an array of all the sheets in this workbook.
-
#strings ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#add_sheet(name) {|sheet| ... } ⇒ Object
Add a new sheet with name.
-
#build ⇒ Object
Get the data.
-
#dump(path = nil) ⇒ Object
Write the data to an .xlsx file.
-
#initialize ⇒ Workbook
constructor
create a new work book.
-
#register_string(string) ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ Workbook
create a new work book
8 9 10 11 |
# File 'lib/xlsx/workbook.rb', line 8 def initialize @sheets = Array.new @strings = Array.new end |
Instance Attribute Details
#sheets ⇒ Object
an array of all the sheets in this workbook.
4 5 6 |
# File 'lib/xlsx/workbook.rb', line 4 def sheets @sheets end |
#strings ⇒ Object
:nodoc:
5 6 7 |
# File 'lib/xlsx/workbook.rb', line 5 def strings @strings end |
Instance Method Details
#add_sheet(name) {|sheet| ... } ⇒ Object
Add a new sheet with name.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/xlsx/workbook.rb', line 14 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 |
#build ⇒ Object
Get the data.
26 27 28 |
# File 'lib/xlsx/workbook.rb', line 26 def build ::XLSX::Formatter.build(self) end |
#dump(path = nil) ⇒ Object
Write the data to an .xlsx file
31 32 33 |
# File 'lib/xlsx/workbook.rb', line 31 def dump(path=nil) ::XLSX::Formatter.dump(self, path) end |
#register_string(string) ⇒ Object
:nodoc:
35 36 37 38 39 40 41 42 |
# File 'lib/xlsx/workbook.rb', line 35 def register_string(string) # :nodoc: index = @strings.index(string) if index.nil? index = @strings.size @strings.push string end index end |