1
votes

So, I want to export my data from database to Ms Word using openXML. I formatting my paragraph as below

para = new Paragraph();
run = new Run(new Text(row["name"].ToString()));

paraProp = new ParagraphProperties();
spacing = new SpacingBetweenLines() { Before = "60", After = "60" };
paraProp.Append(spacing);
para.Append(paraProp);
para.Append(run);

The problem is some data is empty, and this make my paragraph formatting not working.

I try to add empty space like this

run = new Run(new Text(row["name"].ToString() + " "));

But it also not working.

So how to apply paragraph formatting even the data is empty?

1
How is the formatting not working exactly? - Muad'dib

1 Answers

2
votes

I am guessing the empty paragraphs are not spacing properly and causing your formatting issues. Try changing your spacingbetweenlines properties to:

{ After = "60", Before = "60" Line = "240", LineRule = LineSpacingRuleValues.Exact};

The Line value is the height of the line and the and the LineRule sets how the before and after are applied to the paragraph.