def write_comment(*args)
    # Check for a cell reference in A1 notation and substitute row and column
    args = row_col_notation(args)

    return -1 if args.size < 3   # Check the number of args

    row, col, comment, params = args

    # Check for pairs of optional arguments, i.e. an odd number of args.
    # raise "Uneven number of additional arguments" if args.size % 2 == 0

    # Check that row and col are valid and store max and min values
    return -2 unless check_dimensions(row, col) == 0

    if params && params[:start_cell]
      params[:start_row], params[:start_col] = substitute_cellref(params[:start_cell])
    end

    # We have to avoid duplicate comments in cells or else Excel will complain.
    @comments << Comment.new(self, *args)
  end
def write_comment(*args)
    # Check for a cell reference in A1 notation and substitute row and column
    args = row_col_notation(args)

    return -1 if args.size < 3   # Check the number of args

    row, col, comment, params = args

    # Check for pairs of optional arguments, i.e. an odd number of args.
    # raise "Uneven number of additional arguments" if args.size % 2 == 0

    # Check that row and col are valid and store max and min values
    return -2 unless check_dimensions(row, col) == 0

    if params && params[:start_cell]
      params[:start_row], params[:start_col] = substitute_cellref(params[:start_cell])
    end

    # We have to avoid duplicate comments in cells or else Excel will complain.
    @comments << Comment.new(self, *args)
  end
:call-seq:
   write_comment(row, col,    comment[, optionhash(es)])  -> Fixnum
   write_comment(A1_notation, comment[, optionhash(es)])  -> Fixnum

 Write a comment to the specified row and column (zero indexed).

 Returns  0 : normal termination
         -1 : insufficient number of arguments
         -2 : row or column out of range

 The write_comment() method is used to add a comment to a cell. A cell
 comment is indicated in Excel by a small red triangle in the upper
 right-hand corner of the cell. Moving the cursor over the red triangle
 will reveal the comment.

 The following example shows how to add a comment to a cell:

     worksheet.write        (2, 2, 'Hello')
     worksheet.write_comment(2, 2, 'This is a comment.')

 As usual you can replace the row and column parameters with an A1 cell
 reference. See the note about "Cell notation".

     worksheet.write        ('C3', 'Hello')
     worksheet.write_comment('C3', 'This is a comment.')

 On systems with perl 5.8 and later the write_comment() method will also
 handle strings in UTF-8 format.

     worksheet.write_comment('C3', "\x{263a}")       # Smiley
     worksheet.write_comment('C4', 'Comment ca va?')

 In addition to the basic 3 argument form of write_comment() you can pass in
 several optional key/value pairs to control the format of the comment.
 For example:

     worksheet.write_comment('C3', 'Hello', :visible => 1, :author => 'Ruby')

 Most of these options are quite specific and in general the default comment
 behaviour will be all that you need. However, should you need greater
 control over the format of the cell comment the following options are
 available:

     :encoding
     :author
     :author_encoding
     :visible
     :x_scale
     :width
     :y_scale
     :height
     :color
     :start_cell
     :start_row
     :start_col
     :x_offset
     :y_offset

 Option: :encoding

   This option is used to indicate that the comment string is encoded as
   UTF-16BE.

     comment = [0x263a].pack('n')     # UTF-16BE Smiley symbol

     worksheet.write_comment('C3', comment, :encoding => 1)

 Option: :author

   This option is used to indicate who the author of the comment is. Excel
   displays the author of the comment in the status bar at the bottom of
   the worksheet. This is usually of interest in corporate environments
   where several people might review and provide comments to a workbook.

     worksheet.write_comment('C3', 'Atonement', :author => 'Ian McEwan')

 Option: :author_encoding

   This option is used to indicate that the author string is encoded as UTF-16BE.

 Option: :visible

   This option is used to make a cell comment visible when the worksheet
   is opened. The default behaviour in Excel is that comments are initially
   hidden. However, it is also possible in Excel to make individual or all
   comments visible. In WriteExcel individual comments can be made visible
   as follows:

     worksheet.write_comment('C3', 'Hello', :visible => 1)

   It is possible to make all comments in a worksheet visible using the show
   comments() worksheet method (see below). Alternatively, if all of the cell
   comments have been made visible you can hide individual comments:

     worksheet.write_comment('C3', 'Hello', :visible => 0)

 Option: :x_scale

   This option is used to set the width of the cell comment box as a factor
   of the default width.

     worksheet.write_comment('C3', 'Hello', :x_scale => 2)
     worksheet.write_comment('C4', 'Hello', :x_scale => 4.2)

 Option: :width

   This option is used to set the width of the cell comment box
   explicitly in pixels.

     worksheet.write_comment('C3', 'Hello', :width => 200)

 Option: :y_scale

   This option is used to set the height of the cell comment box as a
   factor of the default height.

     worksheet.write_comment('C3', 'Hello', :y_scale => 2)
     worksheet.write_comment('C4', 'Hello', :y_scale => 4.2)

 Option: :height

   This option is used to set the height of the cell comment box
   explicitly in pixels.

     worksheet.write_comment('C3', 'Hello', :height => 200)

 Option: :color

   This option is used to set the background colour of cell comment box.
   You can use one of the named colours recognised by WriteExcel or a colour
   index. See "COLOURS IN EXCEL".

     worksheet.write_comment('C3', 'Hello', :color => 'green')
     worksheet.write_comment('C4', 'Hello', :color => 0x35)    # Orange

 Option: :start_cell

   This option is used to set the cell in which the comment will appear.
   By default Excel displays comments one cell to the right and one cell
   above the cell to which the comment relates. However, you can change
   this behaviour if you wish. In the following example the comment which
   would appear by default in cell D2 is moved to E2.

     worksheet.write_comment('C3', 'Hello', :start_cell => 'E2')

 Option: :start_row

   This option is used to set the row in which the comment will appear.
   See the start_cell option above. The row is zero indexed.

     worksheet.write_comment('C3', 'Hello', :start_row => 0)

 Option: :start_col

   This option is used to set the column in which the comment will appear.
   See the start_cell option above. The column is zero indexed.

     worksheet.write_comment('C3', 'Hello', :start_col => 4)

 Option: :x_offset

   This option is used to change the x offset, in pixels, of a comment
   within a cell:

     worksheet.write_comment('C3', comment, :x_offset => 30)

 Option: :y_offset

   This option is used to change the y offset, in pixels, of a comment
   within a cell:

     worksheet.write_comment('C3', comment, :x_offset => 30)

 You can apply as many of these options as you require.

 ==Note about row height and comments.

 If you specify the height of a row that contains a comment then WriteExcel
 will adjust the height of the comment to maintain the default or user
 specified dimensions. However, the height of a row can also be adjusted
 automatically by Excel if the text wrap property is set or large fonts are
 used in the cell. This means that the height of the row is unknown to
 WriteExcel at run time and thus the comment box is stretched with the row.
 Use the set_row() method to specify the row height explicitly and avoid
 this problem.