private static void CustomDemo() { // TODO: 部分“空”Unicode字符写入word导致word打不开,WPS可以 #region 暂不处理 //var aa = "\u4f60\u597d"; //var bb = "\u0013"; //var cc = ContainsUnicodeCharacter("\u0013"); //var ccc = ContainsUnicodeCharacter("好h"); //var dd = ContainsUnicodeCharacter("\u4f60\u597d"); #endregion wordUtil.CreateDocument("sample.docx"); wordUtil.AddTextParagraph("标题1", new ParagraphOptions { IsTitle = true, TitleSize = "1" }); wordUtil.AddTextParagraph("标题2", new ParagraphOptions { IsTitle = true, TitleSize = "2" }); wordUtil.AddTextParagraph("标题3", new ParagraphOptions { IsTitle = true, TitleSize = "标题 1" }); wordUtil.AddTextParagraph("测试\u4f60\u597d段落1\u263A\u0021\u1F60F"); wordUtil.AddTextParagraph(GetLongText()); wordUtil.AddTextParagraph("测试段落3", new TextOptions { FontStyle = new Word.Styles.FontStyle { ForeColor = "FF00FF" } }); wordUtil.AddMultiTextParagraph(new List <string> { "多段落1", "多段落2", "多段落3" }); wordUtil.AddTextParagraphWithMultiText(new List <string> { "单段落多文本段1", "单段落多文本段2", "单段落多文本段3" }, " | "); wordUtil.AddTextParagraphWithMultiText(GetOneParagraphMultiTextModelFakeData()); wordUtil.AddTextParagraphWithMultiText(GetOneParagraphMultiTextModelFakeData()); // 表格 wordUtil.AddTableParagraph("table name", GetTableModel(5, 10), new ParagraphOptions { Alignment = Word.Styles.Alignment.Center }, new TextOptions { FontStyle = new Word.Styles.FontStyle { IsBold = true } }); wordUtil.AddTextParagraph("--------------------------"); wordUtil.AddTableParagraph("table name", GetTableModel(5, 10), new ParagraphOptions { Alignment = Word.Styles.Alignment.Center }, new TextOptions { FontStyle = new Word.Styles.FontStyle { IsBold = true } }); wordUtil.AddTextParagraph("--------------------------"); wordUtil.SaveDocument(); }