Sandesh Karade
Sandesh Karade

Reputation: 65

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
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

Upvotes: 1

Views: 1808

Answers (1)

Flydog57
Flydog57

Reputation: 7111

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):

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. That tool (downloadable from the Microsoft site) is invaluable when using Open XML. 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.

When I do that, I can see that the difference I can see that the difference is the Line = "240" part. I get the LineRule = LineSpacingRuleValues.Auto on both versions.

By the way, you should be able to ignore the RsidXxxx constants - if I remember correctly, those are for versioning things.

Upvotes: 2

Related Questions