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 unless ptrue?(lastcol)

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

      width, format, hidden, level, collapsed = data

      # Check that cols are valid and store max and min values with default row.
      # NOTE: The check shouldn't modify the row dimensions and should only modify
      #       the column dimensions in certain cases.
      ignore_row = 1
      ignore_col = 1
      ignore_col = 0 if format.respond_to?(:xf_index)   # Column has a format.
      ignore_col = 0 if width && ptrue?(hidden)         # Column has a width but is hidden

      check_dimensions_and_update_max_min_values(0, firstcol, ignore_row, ignore_col)
      check_dimensions_and_update_max_min_values(0, lastcol,  ignore_row, ignore_col)

      # Set the limits for the outline levels (0 <= x <= 7).
      level ||= 0
      level = 0 if level < 0
      level = 7 if level > 7

      @outline_col_level = level if level > @outline_col_level

      # Store the column data based on the first column. Padded for sorting.
      @colinfo[sprintf("%05d", firstcol)] = [firstcol, lastcol, width, format, hidden, level, collapsed]

      # Store the column change to allow optimisations.
      @col_size_changed = 1

      # Store the col sizes for use when calculating image vertices taking
      # hidden columns into account. Also store the column formats.
      width = 0 if ptrue?(hidden)         # Set width to zero if 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 unless ptrue?(lastcol)

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

      width, format, hidden, level, collapsed = data

      # Check that cols are valid and store max and min values with default row.
      # NOTE: The check shouldn't modify the row dimensions and should only modify
      #       the column dimensions in certain cases.
      ignore_row = 1
      ignore_col = 1
      ignore_col = 0 if format.respond_to?(:xf_index)   # Column has a format.
      ignore_col = 0 if width && ptrue?(hidden)         # Column has a width but is hidden

      check_dimensions_and_update_max_min_values(0, firstcol, ignore_row, ignore_col)
      check_dimensions_and_update_max_min_values(0, lastcol,  ignore_row, ignore_col)

      # Set the limits for the outline levels (0 <= x <= 7).
      level ||= 0
      level = 0 if level < 0
      level = 7 if level > 7

      @outline_col_level = level if level > @outline_col_level

      # Store the column data based on the first column. Padded for sorting.
      @colinfo[sprintf("%05d", firstcol)] = [firstcol, lastcol, width, format, hidden, level, collapsed]

      # Store the column change to allow optimisations.
      @col_size_changed = 1

      # Store the col sizes for use when calculating image vertices taking
      # hidden columns into account. Also store the column formats.
      width = 0 if ptrue?(hidden)         # Set width to zero if hidden

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

 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"}[#label-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"}[Format.html#label-CELL+FORMATTING].
 If you wish to set the format without changing the width you can pass
 nil 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()}[#method-i-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 1 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, 1 )
     worksheet.set_column( 'E:E', nil, nil,    1 )

 The +level+ parameter is used to set the outline level of the column.
 Outlines are described in
 {"OUTLINES AND GROUPING IN EXCEL"}["method-i-set_row-label-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, 0, 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, 1, 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, 0, 0, 1 )

 For a more complete example see the outline.rb 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 <tt>0 <= level <= 7</tt>.