如何利用OpenXML SDK 2.0 编程向docx写入含有强制换行符 的字符
2个回答
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;
}
{
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(字符串
不论在windows,Linux还是MAC上都只需用'\n'表示换行符
1
fh.write(字符串
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询