ContextTableFormatting

DocumentBuilderOptions.ContextTableFormatting property

如果应用于表格内容的格式不会影响其后内容的格式,则为 True。 默认值为真的.

public bool ContextTableFormatting { get; set; }

例子

展示如何忽略表格内容的格式。

Document doc = new Document();
DocumentBuilderOptions builderOptions = new DocumentBuilderOptions();
builderOptions.ContextTableFormatting = true;
DocumentBuilder builder = new DocumentBuilder(doc, builderOptions);

// 在表格前添加内容。
// 默认字体大小为 12。
builder.Writeln("Font size 12 here.");
builder.StartTable();
builder.InsertCell();
// 更改表格内的字体大小。
builder.Font.Size = 5;
builder.Write("Font size 5 here");
builder.InsertCell();
builder.Write("Font size 5 here");
builder.EndRow();
builder.EndTable();

// 如果 ContextTableFormatting 为真,则表格格式不会应用于之后的内容。
// 如果 ContextTableFormatting 为 false,则表格格式将应用于之后的内容。
builder.Writeln("Font size 12 here.");

doc.Save(ArtifactsDir + "Table.ContextTableFormatting.docx");

也可以看看