如何利用OpenXML SDK 2.0 编程向docx写入含有强制换行符 的字符

 我来答
匿名用户
2016-03-21
展开全部
public static Paragraph GenerateParagraph()
{
var element =
new Paragraph(
new Run(
new Text("This is the first line")
){ RsidRunProperties = "00CF4A05" },
new Run(
new Break(),
new Text("This is the second line")
){ RsidRunProperties = "00CF4A05" }
){ RsidParagraphMarkRevision = "00CF4A05", RsidParagraphAddition = "00FD48A2", RsidParagraphProperties = "00CF4A05", RsidRunAdditionDefault = "00A03D24" };
return element;
}
OR split these in two separate paragraphs. Effect is same , but the difference comes when we start applying styles to these.
Like this
public static Paragraph GenerateParagraph()
{
var element =
new Paragraph(
new Run(
new Text("This is the first line")
){ RsidRunProperties = "00CF4A05" }
){ RsidParagraphMarkRevision = "00CF4A05", RsidParagraphAddition = "00A03D24", RsidParagraphProperties = "00CF4A05", RsidRunAdditionDefault = "00A03D24" };
return element;
}

public static Paragraph GenerateParagraph()
{
var element =
new Paragraph(
new Run(
new Text("This is the second line")
){ RsidRunProperties = "00CF4A05" }
){ RsidParagraphMarkRevision = "00CF4A05", RsidParagraphAddition = "00A03D24", RsidParagraphProperties = "00CF4A05", RsidRunAdditionDefault = "00A03D24" };
return element;
}
匿名用户
2016-03-21
展开全部
没有,python的换行符是跨平台兼容的,加上一个换行符并不困难啊
不论在windows,Linux还是MAC上都只需用'\n'表示换行符

1

fh.write(字符串
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式