I am currently on CF version 9.0.1 and I'm having trouble getting the SpreadsheetAddImage
function to properly insert an image into the spreadsheet that I am generating. I'm not getting any error message, its just that the image does not display in the spreadsheet. I've also ruled out any issues with finding the image or returning it (tested by using cfimage writetobrowser attribute).
I also stripped out all of my data and formatting from the spreadsheet to rule out anything overwriting that cell's contents. Just to see if I could get a blank spreadsheet with an image.
See sample code below.
<cfset sObj = SpreadsheetNew()>
<!--- <cfimage source="pathtomyimage.jpg" name="image"> --->
<cfset image_var = ImageRead("pathtomyimage.png")>
<cfset SpreadsheetAddRow(sObj, "")>
<cfset SpreadsheetAddImage(sObj,image_var,"png","1,1,1,1")>
...
<cffile action="readbinary" file="#dest_loc#" variable="export_file">
<cffile action="delete" file="#dest_loc#">
<cfheader name="Content-Disposition" value="inline; filename=#file_name#.xls">
<cfcontent type="application/vnd.msexcel" variable="#toBinary(export_file)#">
I appreciate any feedback. Thanks.
I ran your code and found the image did not appear when the
anchor
dimensions were too small. (I also usedSpreadSheetReadBinary
instead of writing the spreadsheet to disk, but that should not make any difference). Try this example from the documentation. If the image is visible, that suggests a problem with the dimensions. To fix it you could either increase the anchor dimensions or use image functions to reduce the size of your image.