简体   繁体   English

使用OOXML对于段落,我想将行距值设置为单个

[英]Using OOXML For a paragraph I want to set Line spacing value to single

Using OOXML for a paragraph I am able to set the spacing after and Before value 使用OOXML进行段落设置,我可以设置after和Before值的间隔
Following is the code 以下是代码

paragraphProperties1.SpacingBetweenLines = new SpacingBetweenLines() { After = "0", Before = "0" };

I want to set the Line spacing to a single value. 我想将行距设置为单个值。
Please check the image 请检查图像

If I open a fresh Word doc, type in some text, set the paragraph settings to 0 points before, 0 points after and "Single" and then save the document, I see this in the Open Xml Productivity tool (a tool you should be using): 如果我打开一个新的Word文档,键入一些文本,将段落设置设置为之前0点,之后0点和“单”,然后保存该文档,那么我将在“打开Xml生产率”工具(该工具应该是使用):

Paragraph paragraph1 = new Paragraph(){ RsidParagraphAddition = "00977688", RsidParagraphProperties = "00ED3794", RsidRunAdditionDefault = "00ED3794" };

ParagraphProperties paragraphProperties1 = new ParagraphProperties();
SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines(){ After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };

paragraphProperties1.Append(spacingBetweenLines1);

At first glance, the difference seems to be the LineRule = LineSpacingRuleValues.Auto . 乍一看,差异似乎是LineRule = LineSpacingRuleValues.Auto That tool (downloadable from the Microsoft site) is invaluable when using Open XML. 使用Open XML时,该工具(可从Microsoft站点下载)非常宝贵。 You can use it to see the code that represents a document (the "Reflect Code" button), or to see the differences between two documents (the "Compare Files" button). 您可以使用它查看代表文档的代码(“反映代码”按钮),或查看两个文档之间的差异(“比较文件”按钮)。

The Compare operation is particularly useful. 比较操作特别有用。 For example, if I took my test Word document and saved it before setting the paragraph setting to "Single", and then set the setting to "Single" and saved another copy, then I could compare the two documents and that one change would be highlighted. 例如,如果我在将段落设置设置为“单个”之前将测试的Word文档保存并保存,然后将设置设置为“单个”并保存了另一个副本,那么我可以比较两个文档,那么一个更改就是突出显示。

When I do that, I can see that the difference I can see that the difference is the Line = "240" part. 当我这样做时,我可以看到差异是Line = "240"部分。 I get the LineRule = LineSpacingRuleValues.Auto on both versions. 我在两个版本上都得到LineRule = LineSpacingRuleValues.Auto

By the way, you should be able to ignore the RsidXxxx constants - if I remember correctly, those are for versioning things. 顺便说一句,您应该能够忽略RsidXxxx常量-如果我没记错的话,这些常量是用于版本控制的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM