class RubyXL::Selection

www.schemacentral.com/sc/ooxml/e-ssml_selection-1.html

Public Instance Methods

before_write_xml() click to toggle source
# File lib/rubyXL/objects/worksheet.rb, line 379
def before_write_xml
  # Normally, rindex of activeCellId in sqref:
  # <selection activeCell="E12" activeCellId="9" sqref="A4 B6 C8 D10 E12 A4 B6 C8 D10 E12"/>
  if @active_cell_id.nil? && !@active_cell.nil? && @sqref.size > 1 then
    # But, things can be more complex:
    # <selection activeCell="E8" activeCellId="2" sqref="A4:B4 C6:D6 E8:F8"/>
    # Not using .reverse.each here to avoid memory reallocation.
    @sqref.each_with_index { |ref, ind| @active_cell_id = ind if ref.cover?(@active_cell) }
  end
  true
end