Class: ReadXls::Workbook::WorksheetBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/read_xls/workbook/worksheet_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWorksheetBuilder

Returns a new instance of WorksheetBuilder.



6
7
8
9
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 6

def initialize
  self.rows            = []
  self.formula_strings = []
end

Instance Attribute Details

#extended_formatsObject

Returns the value of attribute extended_formats.



4
5
6
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 4

def extended_formats
  @extended_formats
end

#formatsObject

Returns the value of attribute formats.



4
5
6
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 4

def formats
  @formats
end

#formula_stringsObject

Returns the value of attribute formula_strings.



4
5
6
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 4

def formula_strings
  @formula_strings
end

#rowsObject

Returns the value of attribute rows.



4
5
6
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 4

def rows
  @rows
end

#sstObject

Returns the value of attribute sst.



4
5
6
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 4

def sst
  @sst
end

Instance Method Details

#add_column_to_row(row_index, column_index, value) ⇒ Object



15
16
17
18
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 15

def add_column_to_row(row_index, column_index, value)
  row = rows[row_index] || raise("could not find row")
  row.add_column(column_index, value)
end

#add_formula_string(string) ⇒ Object



20
21
22
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 20

def add_formula_string(string)
  self.formula_strings.push(string)
end

#add_row(row_index, row) ⇒ Object



11
12
13
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 11

def add_row(row_index, row)
  rows[row_index] = row
end

#buildObject



24
25
26
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 24

def build
  ::ReadXls::Workbook::Worksheet.new(:rows => build_rows)
end

#next_formula_string!Object



28
29
30
# File 'lib/read_xls/workbook/worksheet_builder.rb', line 28

def next_formula_string!
  self.formula_strings.shift
end