PreferredWidthType

PreferredWidthType enumeration

指定表格或单元格的首选宽度的测量单位。

public enum PreferredWidthType

价值观

姓名价值描述
Auto1未指定首选宽度。表格或单元格的实际宽度要么使用显式宽度指定,要么 将在显示表格时由表格布局算法自动确定,具体取决于表格自动调整设置。
Percent2使用指定的百分比测量当前项目的宽度。
Points3使用指定数量的点数(1/72 英寸)测量当前项目的宽度。

例子

演示如何验证表格单元格的首选宽度类型和值。

Document doc = new Document(MyDir + "Tables.docx");

Table table = doc.FirstSection.Body.Tables[0];
Cell firstCell = table.FirstRow.FirstCell;

Assert.AreEqual(PreferredWidthType.Percent, firstCell.CellFormat.PreferredWidth.Type);
Assert.AreEqual(11.16d, firstCell.CellFormat.PreferredWidth.Value);

也可以看看