Method: RubyXL::WorksheetConvenienceMethods#change_column_alignment

Defined in:
lib/rubyXL/convenience_methods/worksheet.rb

#change_column_alignment(column_index, &block) ⇒ Object

[View source]

675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
# File 'lib/rubyXL/convenience_methods/worksheet.rb', line 675

def change_column_alignment(column_index, &block)
  validate_workbook
  ensure_cell_exists(0, column_index)

  cols.get_range(column_index).style_index = @workbook.modify_alignment(get_col_style(column_index), &block)
  # Excel gets confused if width is not explicitly set for a column that had alignment changes
  change_column_width(column_index) if get_column_width_raw(column_index).nil?

  sheet_data.rows.each { |row|
    next if row.nil?
    c = row[column_index]
    next if c.nil?
    c.style_index = @workbook.modify_alignment(c.style_index, &block)
  }
end