I'm currently trying to replace an image in an xlsx file using the FlexCelReport object. Currently I have tried using the "SetValue()" function with the image variable name and the value set to either a filepath to an image on the local filesystem, or actually passing the bytes of the image data as a byte[] array. Neither seem to result in the image being replaced.
I have viewed the online video tutorial where an image is replaced, but this appears to pull the data directly from the database. I was unable to find any other examples or information in the documentation for image replacement.
Does anybody have any ideas as to where I am going wrong?
I've modified my file load code to match your method of obtaining the bytearray and run it through again and still no joy. I'll try to produce a standalone example to test and get back to you with more information. It will probably be Monday before I can do this though (I'm on UK time).
Other information that may be useful:
I'm using MS Excel 2007 and saving the template excel file in the XLSX format.
The image I'm attempting to load into the excel file is a jpeg.
I should have also added, that the Flexcel library doesn't throw any exceptions or errors. The excel template is otherwise populated correctly, and the generated pdf is fine apart from the original image still being there.
I have been investigating the code and I think I have identified a bug that could happen when you use xlsx templates. I will see to fix it and let you know when it is ready.
Please email me to adrian@tmssoftware.com with your registration data and I will send you an url to the fixed version, to see if it works for you
I now have the images successfully being replaced in the XLSX files. I was wondering how to get them to automatically readjust the aspect ratio to suit the new image data. I've tried unchecking the "Lock aspect ratio" option within Excel on the Image object itself. Is there something else I need to do?
You can use the <#imgsize> tag in the name of the image to keep the aspect ratio.
Please take a look at the "Images" demo (in report section) for an example, it show not only how to keep aspect ratio, but other possibilities, like keeping the width, keeping the height, resizing to 50%, centering the image, etc)ç
Also note that in the demo we use expressions, so the tags are in the Config sheet, ans instead of naming the image directly <#Employees.Photo><#ImgSize> we name it PhotoAutoSize and then define the expression PhotoAutoSize to be the full name. This is not such a bad idea, espceially because editing tags in the image name is kind of difficult.