ExcelPicture size stays square

Mar 9, 2015 at 8:34 AM
Dear all,
I am facing a strange behavior on the SetSize() method.
I have got an Image icon in png format and add it to my spreadsheet as
int row = 1, col = 1;
var cell = ws.Cells[row, col, row, col + 11];
cell.Merge = true;
ws.Row(row).Height = 70;

 if (icon != null)
{
  OfficeOpenXml.Drawing.ExcelPicture pic = ws.Drawings.AddPicture("pic" + (row).ToString(), icon);
  pic.SetSize(10,10);
  pic.SetPosition(5, 400);
}
in this case my image is resized correctly as a 10x10 png, but if I resize as
int row = 1, col = 1;
var cell = ws.Cells[row, col, row, col + 11];
cell.Merge = true;
ws.Row(row).Height = 70;

 if (icon != null)
{
  OfficeOpenXml.Drawing.ExcelPicture pic = ws.Drawings.AddPicture("pic" + (row).ToString(), icon);
  pic.SetSize(50,10);
  pic.SetPosition(5, 400);
}
I still got a square image while I expected to be 50x10.

The initial image is a 410x60 png, thus a square image leads to a big distorsion.

Any hint?

Thank you!
Dec 18, 2015 at 2:50 PM
Edited Dec 18, 2015 at 2:51 PM
It appears that setting the any row height mucks with any previously embedded images, even if they are in different rows. The work around for this is to set all of the row heights before embedding images.

In my case it means that I have to loop through and set the row height then do a second loop and embed the images.