Method: Axlsx::Worksheet#initialize

Defined in:
lib/axlsx/workbook/worksheet/worksheet.rb

#initialize(wb, options = {}) ⇒ Worksheet

Note:

the recommended way to manage worksheets is Workbook#add_worksheet

Creates a new worksheet.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • name (String)

    The name of this worksheet.

  • page_margins (Hash)

    A hash containing page margins for this worksheet. @see PageMargins

  • show_gridlines (Boolean)

    indicates if gridlines should be shown for this sheet.

See Also:



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 97

def initialize(wb, options={})
  self.workbook = wb
  @workbook.worksheets << self

  @drawing = @page_margins = @auto_filter = nil
  @merged_cells = []
  @auto_fit_data = []
  @conditional_formattings = []

  @selected = false
  @show_gridlines = true
  self.name = "Sheet" + (index+1).to_s
  @page_margins = PageMargins.new options[:page_margins] if options[:page_margins]

  @rows = SimpleTypedList.new Row
  @column_info = SimpleTypedList.new Col
  # @cols = SimpleTypedList.new Cell
  @tables = SimpleTypedList.new Table

  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
  end
end