SpreadsheetAddImage

Description

Adds an image to an Excel spreadsheet object.

Returns

Does not return a value.

Category

Microsoft Office Integration

Function syntax

SpreadsheetAddImage(SpreadsheetObj, imageFilePath, anchor) 
SpreadsheetAddImage(SpreadsheetObj, imageData, imageType, anchor)

History

ColdFusion 9: Added the function.

Parameters

Parameter

Description

spreadsheetObj

The Excel spreadsheet object to which to add the column.

anchor

The image location, as a comma delimited list in either of the following formats:

  • startRow,startColumn,endRow,endColumn

  • startXPosition,startYPosition,endXPosition,endYPositions,startRow,startColumn,endRow,endColumn

The first format specifies only the row and column numbers, the second also specifies the positions in the cell, using pixel X and Y coordinates relative to the cell upper left corner. If you use the first format, the image corner positions within the top left and bottom right cell are 0,0 and ,0,255.

imageData

A ColdFusion image object.

imageFilePath

The absolute path to the image file.

imageType

The image format, one of the following:

  • jpg or jpeg

  • png

  • dib

Usage

Example

The following example creates a PNG format chart, puts it in a new spread sheet as rows 5-12 and column 5-10, and saves the sheet to disk.

<cfchart format="png" 
    scalefrom="-100" scaleTo="100" 
    gridlines="5" 
    name="test"> 
    <cfchartseries type="line"> 
        <cfchartdata item="Point1" value="-50"> 
        <cfchartdata item="Point2" value="-25"> 
        <cfchartdata item="Point3" value="1"> 
        <cfchartdata item="Point4" value="25"> 
        <cfchartdata item="Point5" value="50"> 
        <cfchartdata item="Point6" value="75"> 
        <cfchartdata item="Point7" value="99"> 
    </cfchartseries> 
</cfchart> 
 
<cfscript> 
       theDir=GetDirectoryFromPath(GetCurrentTemplatePath()); 
    SpreadsheetObj=SpreadsheetNew(); 
    SpreadsheetAddImage(SpreadsheetObj,test,"png","5,5,12,10"); 
</cfscript> 
 
<cfspreadsheet action="write" name=SpreadsheetObj filename="#theDir#imagesheet.xls" 
        sheetname="chart" overwrite=true>