Office Js add-in Excel, Shape Base64 position

Office Js add-in Excel, Shape Base64 position
4

Upvotes

Upvote

 Nov 15 2022
0 Comments 
New

Hi, 

We are experiencing some problems when inserting a shape (image base 64), we use the information to obtain the top and left position of the selected cell to be able to position the image in those coordinates, but we find that this position is usually not correct under certain factors such as zoom, if there are hidden arrows in the sheet

 

Get position and set in shape: 

const activeCell = context.workbook.getActiveCell().load(["address", "top", "left"]);

await context.sync();

 g.cell = activeCell;

.....

const sheet = context.workbook.worksheets.getActiveWorksheet();

const shape = sheet.shapes.addImage(myBase64);

shape.incrementLeft(g.cell.left);

shape.incrementTop(g.cell.top);

shape.top = g.cell.top ;

shape.placement = Excel.Placement.oneCell;

g.cell.select();

await context.sync();

 

 

 

But we detect that sometimes these values of Left and Top are not the correct position of the selected cell, we find some factors like the zoom level, if you have hidden rows before or after from the row where is the active selected cell. 

 

¿How we can do the get the correct position of the selected active cell?