module AxlsxStyler::Workbook

Attributes

styled_cells[RW]

An array that holds all cells with styles

styles_applied[RW]

Checks if styles are indexed to make it work for pre 0.1.5 version users that still explicitly call @workbook.apply_styles

Public Instance Methods

add_styled_cell(cell) click to toggle source
# File lib/axlsx_styler/axlsx_workbook.rb, line 13
def add_styled_cell(cell)
  self.styled_cells ||= Set.new
  self.styled_cells << cell
end
apply_styles() click to toggle source
# File lib/axlsx_styler/axlsx_workbook.rb, line 18
def apply_styles
  return unless styled_cells

  styled_cells.each do |cell|
    current_style = styles.style_index[cell.style]

    if current_style
      new_style = current_style.deep_merge(cell.raw_style)
    else
      new_style = cell.raw_style
    end

    cell.style = styles.add_style(new_style)
  end

  self.styles_applied = true
end