ColumnCount
TextFrameFormat.ColumnCount 属性
返回或设置文本区域中的列数。此值必须是正数。否则,值将被设置为零。值为0表示未定义值。读/写 Int32。
public int ColumnCount { get; set; }
示例
以下示例代码演示如何在 PowerPoint 演示文稿中的文本框内添加列。
[C#]
string outPptxFileName = "ColumnsTest.pptx";
using (Presentation pres = new Presentation())
{
IAutoShape shape1 = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 300, 300);
TextFrameFormat format = (TextFrameFormat)shape1.TextFrame.TextFrameFormat;
format.ColumnCount = 2;
shape1.TextFrame.Text = "所有这些列都被强制保留在一个单一的文本容器中 -- " +
"您可以添加或删除文本 - 新增或剩余的文本会自动调整 " +
"以保持在容器内。然而,您不能让文本从一个容器溢出到另一个容器,因为 PowerPoint 的文本列选项是有限的!";
pres.Save(outPptxFileName, SaveFormat.Pptx);
using (Presentation test = new Presentation(outPptxFileName))
{
Debug.Assert(2 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnCount);
Debug.Assert(double.NaN == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnSpacing);
}
format.ColumnSpacing = 20;
pres.Save(outPptxFileName, SaveFormat.Pptx);
using (Presentation test = new Presentation(outPptxFileName))
{
Debug.Assert(2 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnCount);
Debug.Assert(20 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnSpacing);
}
format.ColumnCount = 3;
format.ColumnSpacing = 15;
pres.Save(outPptxFileName, SaveFormat.Pptx);
using (Presentation test = new Presentation(outPptxFileName))
{
Debug.Assert(3 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnCount);
Debug.Assert(15 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnSpacing);
}
}
另见
- class TextFrameFormat
- namespace Aspose.Slides
- assembly Aspose.Slides