Method: Writeexcel::Worksheet#repeat_columns

Defined in:
lib/writeexcel/worksheet.rb

#repeat_columns(*args) ⇒ Object

:call-seq:

repeat_columns(firstcol[, lastcol])
repeat_columns(A1_notation)

Set the columns to repeat at the left hand side of each printed page. – See also the store_names() methods in Workbook.pm. ++

For large Excel documents it is often desirable to have the first column or columns of the worksheet print out at the left hand side of each page. This can be achieved by using the repeat_columns() method. The parameters firstcolumn and lastcolumn are zero based. The last_column parameter is optional if you only wish to specify one column. You can also specify the columns using A1 column notation, see the note about “Cell notation”.

worksheet1.repeat_columns(0)      # Repeat the first column
worksheet2.repeat_columns(0, 1)   # Repeat the first two columns
worksheet3.repeat_columns('A:A')  # Repeat the first column
worksheet4.repeat_columns('A:B')  # Repeat the first two columns


1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
# File 'lib/writeexcel/worksheet.rb', line 1616

def repeat_columns(*args)
  # Check for a cell reference in A1 notation and substitute row and column
  if args[0] =~ /^\D/
    row1, firstcol, row2, lastcol = substitute_cellref(*args)
  else
    firstcol, lastcol = args
  end

  @title_range.col_min  = firstcol
  @title_range.col_max  = lastcol || firstcol # Second col is optional
end