- Code: Select all
Document document = new Document();
document.ViewSetup.DocumentViewType = DocumentViewType.NormalLayout;
Section section = document.AddSection();
Paragraph para = section.AddParagraph();
para.AppendText("Test 哈哈哈");
string fieldCode = @"\o(\s\do 0(1))";
Field fieldRes = new Field(document);
fieldRes.Code = fieldCode;
fieldRes.Type = FieldType.FieldFormula;
para.ChildObjects.Insert(0, fieldRes);
FieldMark fm = new FieldMark(document, FieldMarkType.FieldEnd);
para.ChildObjects.Insert(1, fm);
document.SaveToFile(@"C:\doc\test.doc", Spire.Doc.FileFormat.Doc);
document.Close();
使用 Spire.Doc 9.7.14 版本
成功顯示 1Test 哈哈哈
使用 Spire.Doc 10.9.6 版本
則只顯示 Test 哈哈哈