Reputation: 1394
I am using C# Interop to generate a word report. I am trying to generate a series of tables that are populated with data from the DB. The tables should be followed by a text that describes the data in the tables. The layout which is required is as follows:
The report is based on a template and the tables and corresponding details are to generated based on a bookmark that is inserted into the template. The issue is that, when I try to populate the text after the table, the text is being inserted in the beginning of the next page. Below is the code snippet that I am using to populate the tables.
foreach (var obj in list)
{
Table vulTable = detailsRange.Tables.Add(detailsRange, 1, 2, ref oMissing, ref oMissing);
vulTable.PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent;
vulTable.Range.InsertBefore("Text");
vulTable.Range.Font.Size = 12;
vulTable.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
vulTable.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
Row r1 = vulTable.Rows.Add(ref oMissing);
//Table generation logic to generate other rows
detailsRange.InsertBreak(WdBreakType.wdColumnBreak);
object strt = vulTable.Range.End;
Range r = doc.Range(ref strt, ref strt);
Paragraph p = r.Paragraphs.Add(ref oMissing);
p.Range.InsertAfter("Details ABCD");
p.Range.InsertBreak(WdBreakType.wdColumnBreak);
p.Range.Bold = 1;
p.Range.Underline = WdUnderline.wdUnderlineSingle;
p.Range.InsertParagraphAfter();
}
As a result of the above code, the "Details ABCD" text is getting populated at the beginning of the next page rather than as a continuation of the table. What modifications or should any other approach be taken other than using the end of current range to insert the Details part? Any help is highly appreciated.
Upvotes: 0
Views: 788
Reputation: 41
ColumnBreak is a new page in a single column document.
From your above description, there should be no breaks at all in your program.
(Ummm, don't confuse them with html .br; just in case you were... :-)
Upvotes: 1