0

我的 Excel 加载项是在 C#(.net framework 4.0) 中为 Office 2010 构建的。

我想将超过 2 个 Shape.Textbox 水平地一个接一个地添加到 excel 单元格中。

我正在使用以下代码:

Range rng = UsedArea.Cells[rownum, cellnum];

txtbox = sheet.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, rng.Left, rng.Top, txt.Width / 2, rng.Height); 

它将文本框添加到单元格的左侧,但是如何在同一单元格中的上一个文本框之后水平添加另一个文本框。

任何帮助,将不胜感激。

4

1 回答 1

0

Need to add the width of the first textbox to the second textbox position.

sample:

        int width = 100;
        int leftpos = 25;
        for (int i = 0; i < 5; i++)
        {
            Excel.Shape textbox = shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, leftpos, 20, width, 20);
            leftpos = leftpos + width;
        }
于 2013-07-11T06:24:26.753 回答