We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Adding image to Excel

Hi,

I'm trying to add an image to an Excel spreadsheet.
The problem is that the image is stretched through all the rows in the Spreadsheet.
Only the rows not the columns.

This is the code that I use and also some comments:

BitmapShapeImpl bitmap = workSheet.Pictures.AddPicture(1, 1, imageStream, 100, 100, ExcelImageFormat.Png) as BitmapShapeImpl;
bitmap.Width = bitmap.Picture.Width;      // the width is correct
bitmap.Height = bitmap.Picture.Height;    // the height is correct
int rowImage = bitmap.BottomRow;    // this is a really high number = 1048576
int columnImage = bitmap.RightColumn; // this is correct = 2


If I open the created Spreadsheet in Excel and check the properties for the image, I get the following:
- Height is 0
- Width is a correct Number
- Adapt Height (a percentage): This is a really high number 3 089 545%
- Adapt Width (a percentage): This is a correct number


This code used to work!
I have done some updates during the last month; for example to the XlsIO component (latest version) and to Xamarin Forms (latest stable version).
Today I noticed that this part of the code did no longer work...I have tried different solutions but nothing seems to help.



Attachment: ExcelExample_df3d9d00.zip

3 Replies

MC Mohan Chandran Syncfusion Team August 8, 2017 01:43 PM UTC

Hi Patrik, 
 
Thank you for using Syncfusion products. 
  
We have tried the code snippet with the document attached and are unable to reproduce the issue at our end. The sample which we tried is shared for your reference and can be downloaded from the following link. 
  
  
Kindly modify the sample to reproduce the issue and share us to investigate further on this and provide a prompt solution at the earliest. 
 
Regards, 
Mohan Chandran. 



PK Patrik K August 9, 2017 12:17 AM UTC

Hi Mohan,

when I checked my project today there were updates available for Syncfusion.Xamarin.XlsIO and Syncfusion.Xamarin.Compression.

I updated from 15.2.0.46 to 15.3.0.26 and after that everything worked again.

Thanks!



MC Mohan Chandran Syncfusion Team August 9, 2017 06:06 AM UTC

Hi Patrik, 
 
We are glad that the issue is resolved at your end. Please let us know if you need any further assistance. 
 
Regards, 
Mohan Chandran. 


Loader.
Up arrow icon