SpreadsheetSetCellComment

Description

Specifies the comment for an Excel spreadsheet object cell.

Returns

Does not return a value.

Category

Microsoft Office Integration

Function syntax

SpreadsheetSetCellComment(spreadsheetObj, comment, row, column)

History

ColdFusion 9: Added the function.

Parameters

Parameter

Description

spreadsheetObj

The Excel spreadsheet object to which to add the comment.

comment

A structure containing the comment including text, formatting, and placement in the cell. See Usage for the structure contents.

row

The row number of the cell to which to add the comment.

column

The column number of the cell to which to add the comment.

Usage

The comment structure can have the following fields. Excel determines the default field values.

Field

Valid values

anchor

A comma separated list of integers specifying the position and size of the comment, in rows and columns, in the order top column, left row,bottom column, right row. For example: "4,8,6,11" specifies a comment with an upper left corner in row 4 column 8 and a lower right corner in row 6 column 11.

author

The author’s name.

bold

A Boolean value specifying whether the text is bold.

color

The text color, Any value in the Apache org.apache.poi.hssf.util.HSSFColor class:

black, brown, olive_green, dark_green, dark_teal, dark_blue, indigo, grey_80_percent, orange, dark_yellow, green, teal, blue, blue_grey, grey_50_percent, red, light_orange, lime, sea_green, aqua, light_blue, violet, grey_40_percent, pink, gold, yellow, bright_green, turquoise, dark_red, sky_blue, plum, grey_25_percent, rose, light_yellow, light_green, light_turquoise, light_turquoise, pale_blue, lavender, white, cornflower_blue, lemon_chiffon, maroon, orchid, coral, royal_blue, light_cornflower_blue.

comment

A string containing the comment text.

fillcolor

A J2SE v1.4 java.awt.Color class color value: white, lightGray, light_gray, gray, darkGray, dark_gray, black, red, pink, orange, yellow, green, magenta, cyan, blue. (Because ColdFusion is case independent, you do not need to specify the values if defined in the Java class.)

font

Any valid system font name.

horizontalalignment

The horizontal alignment of the text: left, center, right, justify, distributed.

italic

A Boolean value specifying whether the text is italic.

linestyle

The style of the top and right borders of the comment box: solid, dashsys, dotsys, dashdotsys, dashdotdotsys, dotgel, dashgel, longdashgel, dashdotgel, longdashdotgel, longdashdotdotgel.

linestylecolor

A Java color value (Does not work: BUG 72501).

size

The size of the text in points.

strikeout

A Boolean value specifying whether the text is struck out.

underline

A Boolean value specifying whether the text is underlined.

verticalalignment

The vertical alignment of the text: top, center, bottom, justify, distributed.

visible

A Boolean value specifying whether the text is visible.

Example

The following example sets and gets a comment for the cell at row 3column 5.

<cfscript> 
    ///We need an absolute path, so get the current directory path. 
       theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "comment.xls"; 
    //Create an Excel spreadsheet object. 
    theSheet = SpreadsheetNew(); 
    // Define a cell comment. 
 
    comment1-structNew() 
    comment1.anchor="0,0,5,8"; 
    comment1.author="Adobe Systems"; 
    comment1.bold="true"; 
    comment1.color="dark_green"; 
    comment1.comment="This is the cell in row three, column 5 (E)."; 
    comment1.fillcolor="light_gray"; 
    comment1.font="Courier"; 
    comment1.horizontalalignment="left"; 
    comment1.linestyle="dashsys"; 
    comment1.size="10"; 
    comment1.verticalalignment="top"; 
     
    //Set the comment. 
    SpreadsheetSetCellComment(theSheet,comment1,3,5); 
    //Get the comment from the Excel spreadsheet object. 
    theComment=SpreadsheetGetCellComment(theSheet,3,5); 
</cfscript> 
 
<cfoutput> 
Row,Column: #theComment.row#,#theComment.column#<br /> 
Author: #theComment.author#<br /> 
Comment: #theComment.comment# 
</cfoutput> 
 
<!--- Write the spreadsheet to a file, replacing any existing file. ---> 
<cfspreadsheet action="write" filename="#theFile#" name="theSheet" 
    sheet=1 sheetname="courses" overwrite=true>