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
close icon

How to insert picture in Excel file

Hi,

My excel file is not open in case while insert picture in excel file.
"AddPicture" method allow to add image . but my sheet is not view .

my code is
ExcelEngine oengine = new ExcelEngine();
IApplication oApp = oengine.Excel;
oApp.DefaultVersion = ExcelVersion.Excel2007;
IWorkbook oWorkbook  =  oApp.Workbooks.Create(1);
IWorksheets osheets = oWorkbook.Worksheets;
IWorksheet  osheet = osheets .Worksheets[0];

 StorageFolder tmpFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("TmpFolder");
 StorageFile Imagefile1 = await tmpFolder.GetFileAsync(ImgName);
 Stream imageStream1 = await Imagefile1.OpenStreamForReadAsync();            

 osheet .Pictures.AddPicture(1, 5, 4, 9, imageStream1);   

Excel file is attach with mail which is not open .
Thanks

Attachment: Repaired_pngmultiimagetest_e37ace53.rar

5 Replies

AV Abirami Varadharajan Syncfusion Team September 2, 2016 09:31 AM UTC

Hi Sharad, 
 
Thank you for contacting syncfusion support. 
 

We are able to reproduce issue with “File gets corrupted in Excel 2007 while adding picture”. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates. 

  

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents  

  

Please let us know if you have any questions. 

 
Regards, 
Abirami. 



SK Sharad Kumar September 28, 2016 10:09 AM UTC

Hi,

if window application is running in release mode. Maximum time picture are not recover in recover excel file.
kindly provide best solution.

I am using same code for given previous question.

Thanks
sharad kumar


AV Abirami Varadharajan Syncfusion Team September 29, 2016 12:40 PM UTC

Hi Sharad,
 
We are unable to reproduce the issue. However, the issue with “File gets corrupted in Excel 2007 while adding picture” was fixed and included in our 14.1 version.
 
We also recommend you to upgrade to the latest version (14.3), which has more enhancements and fixes. The latest version of Syncfusion Essential Studio can be downloaded from the following link.  
  
  
If you still have issue in 14.3v, then kindly share us the image which you are trying to insert. This will be helpful for us to provide prompt solution at the earliest.
  
Regards, 
Abirami. 



SK Sharad Kumar September 30, 2016 10:11 AM UTC

hi,

I am working on latest version 14.3.
Code snippet is given below . this code is working 1 out of 30 .
for(int i = 0;i<4;i++)
{
                StorageFolder tmpFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("TmpFolder");
                StorageFile Imagefile1 = await tmpFolder.GetFileAsync(ImgName);
                Stream imageStream1 = await Imagefile1.OpenStreamForReadAsync();   
                try
                {
                        if(i==0)
                             osheet .Pictures.AddPicture(1, 1, imageStream1);   
                       else if(i==1)
                             osheet .Pictures.AddPicture(5, 8, imageStream1);  
                       else if(i==2)
                             osheet .Pictures.AddPicture(7, 9, imageStream1);  
                }
                catch (Exception e)
                {
                 }
}
Maximum time osheet(Worksheet class object) object through exception "Message = "Index was outside the bounds of the array."
Files are attach which through exception.

Thanks
Sharad kumar


Attachment: 0011162_9a05bc2c.rar


AV Abirami Varadharajan Syncfusion Team October 3, 2016 12:45 PM UTC

Hi Sharad, 
 
Thank you for updating us. 
 

We are able to reproduce the issue with “Exception thrown while adding picture in UWP”. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates.  

   

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents   

   

Regards, 
Abirami. 


SIGN IN To post a reply.
Loader.
Live Chat Icon For mobile
Up arrow icon