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

    # Ensure at least firstcol, lastcol and width
    return unless firstcol && lastcol && !data.empty?

    # Assume second column is the same as first if 0. Avoids KB918419 bug.
    lastcol = firstcol if lastcol == 0

    # Ensure 2nd col is larger than first. Also for KB918419 bug.
    firstcol, lastcol = lastcol, firstcol if firstcol > lastcol

    # Limit columns to Excel max of 255.
    firstcol = ColMax - 1 if firstcol > ColMax - 1
    lastcol  = ColMax - 1 if lastcol  > ColMax - 1

    @colinfo << ColInfo.new(firstcol, lastcol, *data)

    # Store the col sizes for use when calculating image vertices taking
    # hidden columns into account. Also store the column formats.
    #
    width, format, hidden = data

    width  ||= 0                    # Ensure width isn't undef.
    width = 0 if hidden && hidden != 0  # Set width to zero if col is hidden

    (firstcol .. lastcol).each do |col|
      @col_sizes[col]   = width
      @col_formats[col] = format if format
    end
  end
def set_column(*args)
    # Check for a cell reference in A1 notation and substitute row and column
    if args[0] =~ /^\D/
      row1, firstcol, row2, lastcol, *data = substitute_cellref(*args)
    else
      firstcol, lastcol, *data = args
    end

    # Ensure at least firstcol, lastcol and width
    return unless firstcol && lastcol && !data.empty?

    # Assume second column is the same as first if 0. Avoids KB918419 bug.
    lastcol = firstcol if lastcol == 0

    # Ensure 2nd col is larger than first. Also for KB918419 bug.
    firstcol, lastcol = lastcol, firstcol if firstcol > lastcol

    # Limit columns to Excel max of 255.
    firstcol = ColMax - 1 if firstcol > ColMax - 1
    lastcol  = ColMax - 1 if lastcol  > ColMax - 1

    @colinfo << ColInfo.new(firstcol, lastcol, *data)

    # Store the col sizes for use when calculating image vertices taking
    # hidden columns into account. Also store the column formats.
    #
    width, format, hidden = data

    width  ||= 0                    # Ensure width isn't undef.
    width = 0 if hidden && hidden != 0  # Set width to zero if col is hidden

    (firstcol .. lastcol).each do |col|
      @col_sizes[col]   = width
      @col_formats[col] = format if format
    end
  end
:call-seq:
   set_column(first_col, last_col, width, format, hidden, level, collapsed)
   set_column(A1_notation,         width, format, hidden, level, collapsed)

 Set the width of a single column or a range of columns.
--
 See also: store_colinfo
++

 This method can be used to change the default properties of a single
 column or a range of columns. All parameters apart from _first_col_ and
 _last_col_ are optional.

 If set_column() is applied to a single column the value of _first_col_ and
 _last_col_ should be the same. In the case where _last_col_ is zero it is
 set to the same value as _first_col_.

 It is also possible, and generally clearer, to specify a column range
 using the form of A1 notation used for columns. See the note about
 "Cell notation".

 Examples:

     worksheet.set_column(0, 0,  20) # Column  A   width set to 20
     worksheet.set_column(1, 3,  30) # Columns B-D width set to 30
     worksheet.set_column('E:E', 20) # Column  E   width set to 20
     worksheet.set_column('F:H', 30) # Columns F-H width set to 30

 The width corresponds to the column width value that is specified in Excel.
 It is approximately equal to the length of a string in the default font
 of Arial 10. Unfortunately, there is no way to specify "AutoFit" for a
 column in the Excel file format. This feature is only available at
 runtime from within Excel.

 As usual the _format_ parameter is optional, for additional information,
 see "CELL FORMATTING". If you wish to set the format without changing the
 width you can pass undef as the width parameter:

     worksheet.set_column(0, 0, nil, format)

 The _format_ parameter will be applied to any cells in the column that
 don't have a format. For example

     worksheet.set_column('A:A', nil, format1)   # Set format for col 1
     worksheet.write('A1', 'Hello')              # Defaults to format1
     worksheet.write('A2', 'Hello', format2)     # Keeps format2

 If you wish to define a column format in this way you should call the
 method before any calls to write(). If you call it afterwards it won't
 have any effect.

 A default row format takes precedence over a default column format

     worksheet.set_row(0, nil,        format1)   # Set format for row 1
     worksheet.set_column('A:A', nil, format2)   # Set format for col 1
     worksheet.write('A1', 'Hello')              # Defaults to format1
     worksheet.write('A2', 'Hello')              # Defaults to format2

 The _hidden_ parameter should be set to true if you wish to hide a column.
 This can be used, for example, to hide intermediary steps in a complicated
 calculation:

     worksheet.set_column('D:D', 20,  format, true)
     worksheet.set_column('E:E', nil, nil,    true)

 The _level_ parameter is used to set the outline level of the column.
 Outlines are described in "OUTLINES AND GROUPING IN EXCEL". Adjacent
 columns with the same outline level are grouped together into a single
 outline.

 The following example sets an outline level of 1 for columns B to G:

     worksheet.set_column('B:G', nil, nil, true, 1)

 The _hidden_ parameter can also be used to hide collapsed outlined columns
 when used in conjunction with the _level_ parameter.

     worksheet.set_column('B:G', nil, nil, true, 1)

 For collapsed outlines you should also indicate which row has the
 collapsed + symbol using the optional _collapsed_ parameter.

     worksheet.set_column('H:H', nil, nil, true, 0, true)

 For a more complete example see the outline.pl and outline_collapsed.rb
 programs in the examples directory of the distro.

 Excel allows up to 7 outline levels. Therefore the _level_ parameter
 should be in the range 0 <= level <= 7.