有没有办法在Office.js中获取线形的end/beginning坐标?

Is there a method to get the end/beginning coordinates of a line shape in Office.js?

我试图在某些线条形状的 end/beginning 点放置一个文本框,但似乎无法弄清楚如何获取放置文本框形状的线条坐标。我尝试使用 connectBeginShape 方法,但它似乎不适用于文本框。

我觉得可以用shape.leftshape.top,用这2个API,可以得到起点的坐标,可以用shape.widthshape.height 与起点一起计算终点坐标。

这里有一个示例代码供参考。

 await Excel.run(async (context) => {
    const shapes = context.workbook.worksheets.getItem("Shapes").shapes;
    var line = shapes.getItem("StraightLine");
    line.load();
    await context.sync();
    var x1 = line.left;
    var y1 = line.top;
    var x2 = line.left + line.width;
    var y2 = line.top + line.height;
    console.log("X1=" + x1 + ";Y1=" + y1);
    console.log("X2=" + x2 + ";Y2=" + y2);
    await context.sync();
  });

请注意:shape.left 将 return 一个数字,即从形状左侧到工作表左侧的距离(以磅为单位)。