Hello,
API documentation says that there is not "getCellAddressString" method exposed by the topLeftCornerCell. You should instead pass a cell object to it as follows:
imageShape.topLeftCornerCell(sheet.getCell('C9'));
Please let me know if this solves the situation.
Thanks for the reply, but it does not solve the problem. It shows the below error
Cannot call method 'getHashCode' of null
Please help asap
Thanks,
No , the issue hasn't solved it yet. I dropped this process and took another way to attach an image in excel. I had created an html table and export it to an excel. In that way I can be able to attach an image. Hope that helps.
Thanks.
Do you have a sample of the workaround of the process you applied for your problem? And did you use the ig worksheet to add image to excel?
Hi,
The issue is released and will be available in the service release trhat is scheduled to roll out on 24 March 2017. Please let me know if you have further questions.
Could you provide the code for add an image to the excel sheet
Here it is:
var image = new Image(); image.width = 400; image.height = 400; image.src = "banner.jpg"; var imageShape = new $.ig.excel.WorksheetImage(image); imageShape.topLeftCornerCell(sheet.getCell('C9')); imageShape.bottomRightCornerCell(sheet.getCell('D10')); worksheet.shapes().add(imageShape);
Hi Mathew,
You can download a working sample demonstrating how to insert image in Excel at https://ko.infragistics.com/community/forums/p/109480/515305.aspx#515305
I don't understand why you would not be able to execute code that creates an Excel worksheet in the image onload event, I think this should be possible, so you can send us a sample if you need assistance on this.
This also does not work as by the time the export happens the image has not loaded and that a shape of 0 width and 0 height is added and leaves me with a blank cell.
Unfortunately this function does not allow me to even inject the code into the onload function as this is then not possible to wait on so that the export does not continue regardless and add no images.
var image = new Image(50, 50);
image.src = args.cellValue;
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext("2d").drawImage(image, 0, 0);
var imageUrl = canvas.toDataURL();
var imageShape = new $.ig.excel.WorksheetImage(imageUrl );
I seem to be experiencing this exact same issue:
// empty the cell args.xlRow.setCellValue(args.columnIndex, "");
var xlCell = args.xlRow.cells(args.columnIndex);
// load the image var image = new Image(50, 50); image.src = args.cellValue; var imageShape = new $.ig.excel.WorksheetImage(image);
// insert image into the workbook imageShape.topLeftCornerPosition({ x: 0.0, y: 0.0 }); imageShape.bottomRightCornerPosition({ x: 100.0, y: 100.0 }); imageShape.topLeftCornerCell(xlCell); imageShape.bottomRightCornerCell(xlCell); sender._worksheet.shapes().add(imageShape);
Any help on this issue would be great or is this just something that is not going to be supported?
Hello Maanesh,
It is recommended to use base 64 encoded image, currently you cannot pass an image element to create a WorksheetImage. If you want to use Image my suggestion is to draw it into a canvas and then use the toDataUrl to have it create a data url that you could then use when creating a WorksheetImage.
Related thread with a sample:
https://ko.infragistics.com/community/forums/p/109480/515305.aspx#515305
Code snippet:
// Add imagevar image = "data:image/png;base64,iVB..."
var imageShape = new $.ig.excel.WorksheetImage(image); imageShape.topLeftCornerCell(sheet.getCell('C9'));imageShape.bottomRightCornerCell(sheet.getCell('F10'));sheet.shapes().add(imageShape);
Let me know if I can be of further assistance.