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


I can't figure out how ShapeImpl.LeftColumnOffset works when trying to position a picture shape within a cell. I assumed the offset would be in pixels but it doesn't appear to be.

For instance I try to centre a shape by setting the LeftColumnOffset to (column width in pixels - shape width) / 2, but this only moves it a small amount.

Is there any documentation on this property? I can't seem to find any.

6 Replies

DB Dilli Babu Nandha Gopal Syncfusion Team February 18, 2016 11:41 AM UTC

Hi Mark,

The position of the shape can be adjusted through Left and Top Property of ShapeImpl. These properties are measured as pixel units and LeftColumnOffset property is measured in EMU units. The following code snippets illustrates how to position an image.

Code example:

//Positioning a Picture

IShape shape = worksheet.Pictures.AddPicture(1,1,GetFullTemplatePath("logo.png"));

ShapeImpl shapeImpl = shape as ShapeImpl;

//Positioning a Picture

shapeImpl.Left  = 20;
shapeImpl.Top = 10;

We have also shared a sample for your reference which can be downloaded from following link.

Sample link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/InsertImage333251025

To know more about positioning and resizing picture, kindly go through the following UG documentation link.

UG Documentation link: http://help.syncfusion.com/file-formats/xlsio/working-with-pictures#positioning-and-re-sizing-pictures


Dilli babu.

MA Mark February 18, 2016 09:48 PM UTC


So I should be summing the width of all preceding columns to get the absolute .Left position?

Also is the LeftColumnOffset property using EM units - so it is related to font size?

DB Dilli Babu Nandha Gopal Syncfusion Team February 19, 2016 10:42 AM UTC

Hi Mark,

Regarding shape position:

It is not necessary to calculate column width of preceding column instead you can place the shape to its nearest cell by using LeftColumn and TopRow property. If you want to adjust its position, then set its Left and Top property before setting its cell position. The following code example illustrates this behavior.

Code example:

IShape shape = worksheet.Pictures.AddPicture(GetFullTemplatePath("logo.png"));

ShapeImpl shapeImpl = shape as ShapeImpl;

//Positioning a Picture.

shapeImpl.Left = 20;

shapeImpl.Top = 10;

// Setting the picture to a cell.

shapeImpl.LeftColumn = 5;
shapeImpl.TopRow = 5;

We have also shared the sample for your reference which can be downloaded from following link.

Sample link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/InsertImage565015846.zip

Regarding EM Units:

                LeftColumnOffset property is measured in EM units and it does not depends on font size.


Dilli babu.

MA Mark February 21, 2016 09:20 PM UTC

Thank you! You need to set the Left and Top properties BEFORE setting the cell position - I couldn't find this anywhere in the knowledge base (it's also counter-intuitive)

Thanks again - it's working now

MA Mark February 22, 2016 04:38 AM UTC

I spoke too soon. This only works if the column you are trying to place the picture in is the same width as the first column (column A)

I'm not sure if I'm missing something here...

Setting the Left property assigns a LeftColumnOffset value and it seems to use this value when you assign the picture to the cell you want. The problem is that the LeftColumnOffset property appears to be relative to the width of the column.

You can see this in the Sample you sent me which I have altered and attached.

I have inserted a second picture, only this time I first set the width of column A to 1000. When I open the workbook the pictures are not aligned.

Attachment: InsertImage_2df30c21.zip

DB Dilli Babu Nandha Gopal Syncfusion Team February 23, 2016 04:03 AM UTC

Hi Mark,
We considered the requirement “Shapes left ant top position is changed while setting ColumnWidth propert” as a bug. We have logged a report on this and will fix the issue internally, also the fix will be included in our next main release 14.1, which has been scheduled to be rolled out in the month of March 2016.

We have also created an incident internally to have a follow up with this issue.

Dilli babu.

Live Chat Icon For mobile
Up arrow icon