PreferredWidth

Table.PreferredWidth property

获取或设置表格首选宽度。

public PreferredWidth PreferredWidth { get; set; }

评论

默认值为Auto

例子

演示如何将表格设置为自动适合页面宽度的 50%。

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();
builder.InsertCell();
builder.Write("Cell #1");
builder.InsertCell();
builder.Write("Cell #2");
builder.InsertCell();
builder.Write("Cell #3");

table.PreferredWidth = PreferredWidth.FromPercent(50);

doc.Save(ArtifactsDir + "DocumentBuilder.InsertTableWithPreferredWidth.docx");

也可以看看