Hi Team,
Could you please assist me on below query. How to remove spacing in aspose word template table. And how to create aspose word template with same alignment with respect to a reference rdlc report.
Below mentioned screenshot, decrease 1 line space between AppliedStandard and Witnessedby. Not able to reduce space in this area.
Attached both template and generated report for reference below
FullReport_Applied Voltage03-12-2025_ISOCoverPage.docx (4.5 MB)
.
coverTemplateISO17025.docx (33.9 KB)
@rose.thomas
How to remove the extra line between the two rows in the Word table (Aspose.Words + LINQ Reporting Engine)
-
Edit the template – paragraph spacing
- Open coverTemplateISO17025.docx in Word.
- Place the cursor in the AppliedStandard row (or the empty paragraph that appears between the two rows).
- Open Home → Paragraph dialog → Indents and Spacing.
- Set Spacing Before and Spacing After to 0 pt and make sure Line spacing is Single.
- Save the template.
- The LINQ Reporting Engine will keep these paragraph settings when it fills the table, so the extra line disappears.
-
If the spacing is caused by row height
- In the template, select the whole row that contains AppliedStandard (or Witnessedby).
- Right‑click → Table Properties → Row tab.
- Uncheck “Specify height” or set Height to Exactly 0 pt (or a small value) and Height rule to Exactly.
- Save the template.
-
Programmatic fallback (if you cannot change the template manually)
// doc – the loaded template
Document doc = new Document("coverTemplateISO17025.docx");
// Find the two rows by their placeholder text (used by LINQ engine)
Row appliedRow = doc.GetChildNodes(NodeType.Row, true)
.Cast<Row>()
.FirstOrDefault(r => r.ToTxt().Contains("AppliedStandard"));
Row witnessedRow = doc.GetChildNodes(NodeType.Row, true)
.Cast<Row>()
.FirstOrDefault(r => r.ToTxt().Contains("Witnessedby"));
if (appliedRow != null && witnessedRow != null)
{
// Remove any extra paragraph spacing in the rows
foreach (Cell cell in appliedRow.Cells)
foreach (Paragraph p in cell.GetChildNodes(NodeType.Paragraph, true))
p.ParagraphFormat.SpaceAfter = 0;
foreach (Cell cell in witnessedRow.Cells)
foreach (Paragraph p in cell.GetChildNodes(NodeType.Paragraph, true))
p.ParagraphFormat.SpaceAfter = 0;
// Optional: enforce exact row height
appliedRow.RowFormat.Height = 0;
appliedRow.RowFormat.HeightRule = HeightRule.Exactly;
witnessedRow.RowFormat.Height = 0;
witnessedRow.RowFormat.HeightRule = HeightRule.Exactly;
}
// Continue with LINQ report generation
var engine = new ReportingEngine();
engine.BuildReport(doc, dataSource, "Report.docx");
- Keeping alignment identical to an RDLC report
- Replicate the RDLC page settings in the Word template:
- Page Layout → Margins – set the same left/right/top/bottom values.
- Table Properties → Alignment – set Center, Left, or Right to match the RDLC table alignment.
- Ensure the table’s Preferred width is set to the same absolute width (or percentage) used in the RDLC layout.
Next steps
- Apply the paragraph‑spacing changes in the template and re‑run the LINQ report.
- If the extra line persists, run the small code snippet above to force the row height/paragraph spacing at runtime.
If you still see a gap, please provide the Aspose.Words version you are using and a minimal reproducible snippet (loading the template and calling ReportingEngine.BuildReport). That will let us verify whether any version‑specific behavior is involved.
@rose.thomas
There is a paragraph break after the closing foreach tag in the cell located under <<[lang.GetString(“AppliedStandard”)]>>. It seems like removing the paragraph break should do the job.
Hi,
I have tried to remove the space, but no change occurred in the report. Could you pls correct the same in the attached template?
Output should look likes as below (Required):
Currently report showing as below:
@rose.thomas
In my previous reply, I was talking about the paragraph break after the closing foreach tag specifically. Have you tried to remove the paragraph break?
If removal of the paragraph break does not help, please try using ReportBuildOptions.RemoveEmptyParagraphs as follows:
ReportingEngine engine = new ReportingEngine();
engine.Options | = ReportBuildOptions.RemoveEmptyParagraphs;
engine.BuildReport(...);
See Removing Paragraphs with Template Syntax Tags for more information.