def filter_column(col, expression)
    raise "Must call autofilter() before filter_column()" if @filter_area.count == 0

    # Check for a column reference in A1 notation and substitute.
    # Convert col ref to a cell ref and then to a col number.
    dummy, col = substitute_cellref("#{col}1") if col =~ /^\D/

    # Reject column if it is outside filter range.
    unless @filter_area.inside?(col)
      raise "Column '#{col}' outside autofilter() column range " +
        "(#{@filter_area.col_min} .. #{@filter_area.col_max})"
    end

    tokens = extract_filter_tokens(expression)

    unless (tokens.size == 3 or tokens.size == 7)
      raise "Incorrect number of tokens in expression '#{expression}'"
    end

    @filter_cols[col] = parse_filter_expression(expression, tokens)
    @filter_on        = 1
  end
def filter_column(col, expression)
    raise "Must call autofilter() before filter_column()" if @filter_area.count == 0

    # Check for a column reference in A1 notation and substitute.
    # Convert col ref to a cell ref and then to a col number.
    dummy, col = substitute_cellref("#{col}1") if col =~ /^\D/

    # Reject column if it is outside filter range.
    unless @filter_area.inside?(col)
      raise "Column '#{col}' outside autofilter() column range " +
        "(#{@filter_area.col_min} .. #{@filter_area.col_max})"
    end

    tokens = extract_filter_tokens(expression)

    unless (tokens.size == 3 or tokens.size == 7)
      raise "Incorrect number of tokens in expression '#{expression}'"
    end

    @filter_cols[col] = parse_filter_expression(expression, tokens)
    @filter_on        = 1
  end
:call-seq:
   filter_column(column, expression)

 Set the column filter criteria.

 The filter_column method can be used to filter columns in a autofilter
 range based on simple conditions.

 NOTE:
 It isn't sufficient to just specify the filter condition. You must also
 hide any rows that don't match the filter condition. Rows are hidden using
 the set_row() visible parameter. WriteExcel cannot do this
 automatically since it isn't part of the file format. See the autofilter.rb
 program in the examples directory of the distro for an example.

 The conditions for the filter are specified using simple expressions:

     worksheet.filter_column('A', 'x > 2000')
     worksheet.filter_column('B', 'x > 2000 and x < 5000')

 The _column_ parameter can either be a zero indexed column number or a
 string column name.

 The following operators are available:

     Operator        Synonyms
        ==           =   eq  =~
        !=           <>  ne  !=
        >
        <
        >=
        <=

        and          &&
        or           ||

 The operator synonyms are just syntactic sugar to make you more comfortable
 using the expressions. It is important to remember that the expressions will
 be interpreted by Excel and not by ruby.

 An expression can comprise a single statement or two statements separated by
 the and and or operators. For example:

     'x <  2000'
     'x >  2000'
     'x == 2000'
     'x >  2000 and x <  5000'
     'x == 2000 or  x == 5000'

 Filtering of blank or non-blank data can be achieved by using a value of
 Blanks or NonBlanks in the expression:

     'x == Blanks'
     'x == NonBlanks'

 Top 10 style filters can be specified using a expression like the
 following:

     Top|Bottom 1-500 Items|%

 For example:

     'Top    10 Items'
     'Bottom  5 Items'
     'Top    25 %'
     'Bottom 50 %'

 Excel also allows some simple string matching operations:

     'x =~ b*'   # begins with b
     'x !~ b*'   # doesn't begin with b
     'x =~ *b'   # ends with b
     'x !~ *b'   # doesn't end with b
     'x =~ *b*'  # contains b
     'x !~ *b*'  # doesn't contains b

 You can also use * to match any character or number and ? to match any
 single character or number. No other regular expression quantifier is
 supported by Excel's filters. Excel's regular expression characters can
 be escaped using ~.

 The placeholder variable x in the above examples can be replaced by any
 simple string. The actual placeholder name is ignored internally so the
 following are all equivalent:

     'x     < 2000'
     'col   < 2000'
     'Price < 2000'

 Also, note that a filter condition can only be applied to a column in a
 range specified by the autofilter() Worksheet method.

 See the autofilter.rb program in the examples directory of the distro
 for a more detailed example.