SetBorder
Table.SetBorder method
将指定的表格边框设置为指定的线条样式、宽度和颜色。
public void SetBorder(BorderType borderType, LineStyle lineStyle, double lineWidth, Color color,
bool isOverrideCellBorders)
范围 | 类型 | 描述 |
---|---|---|
borderType | BorderType | 要改变的表格边框。 |
lineStyle | LineStyle | 要应用的线条样式。 |
lineWidth | Double | 要设置的线宽(以点为单位)。 |
color | Color | 边框使用的颜色。 |
isOverrideCellBorders | Boolean | 什么时候真的 ,导致所有现有的显式单元格边框被删除。 |
例子
展示如何将外框应用于表格。
Document doc = new Document(MyDir + "Tables.docx");
Table table = doc.FirstSection.Body.Tables[0];
// 将表格与页面中心对齐。
table.Alignment = TableAlignment.Center;
// 清除表格中所有现有的边框和阴影。
table.ClearBorders();
table.ClearShading();
// 为表格轮廓添加绿色边框。
table.SetBorder(BorderType.Left, LineStyle.Single, 1.5, Color.Green, true);
table.SetBorder(BorderType.Right, LineStyle.Single, 1.5, Color.Green, true);
table.SetBorder(BorderType.Top, LineStyle.Single, 1.5, Color.Green, true);
table.SetBorder(BorderType.Bottom, LineStyle.Single, 1.5, Color.Green, true);
// 用浅绿色纯色填充单元格。
table.SetShading(TextureIndex.TextureSolid, Color.LightGreen, Color.Empty);
doc.Save(ArtifactsDir + "Table.SetOutlineBorders.docx");
也可以看看
- enum BorderType
- enum LineStyle
- class Table
- 命名空间 Aspose.Words.Tables
- 部件 Aspose.Words