This project has moved and is read-only. For the latest updates, please go here.

Incorrect image sizes in all but last row

Jun 16, 2012 at 9:21 PM
Edited Jun 16, 2012 at 9:22 PM

Hello,

 

Really enjoying the EPPlus library, but I'm having an issue inserting an image into each row of an Excel file. I tried to mimic the calls in a previous discussion thread (http://epplus.codeplex.com/discussions/229134), but all the images except the image in the final row seem to be sized incorrectly. In fact, when I tried adjusting the sizes of the images by setting the height to half of the actual image height (just to see what would happen), only the final row was affected; the rest were the same (incorrect) size they had been before. Not sure what I'm doing wrong, but here's my approach:

 

     var image = Image.FromStream(s);
     row.Height = ConvertPixelsToRowHeight(image.Height);
     sheet.Column(columnNumber).Width = ConvertPixelsToColumnWidth(sheet, image.Width + 1);
                        
     ExcelPicture picture = sheet.Drawings.AddPicture("Row-" + rowNumber.ToString() + "-Col-" + columnNumber.ToString(), image);
     picture.SetPosition(rowNumber - 1, 2, columnNumber - 1, 2);
     picture.SetSize(image.Width, image.Height);

 

Any assistance is greatly appreciated. Thanks very much,

- Daniel

Sep 20, 2012 at 12:23 AM

I'm having the same problem as Daniel.

Has there been a solution?

Thanks

Frédéric

Mar 8, 2013 at 10:37 PM
You have to set all the row heights first, before you embed a single image. The minute you touch a row height it distorts all the images again.