Using OpenXML what I'm trying to do is insert a table into a Word document. This works fine, but now I need the table to break across two Word columns (as in the newspaper type columns in Word, not as in the column of the table itself). So in Word itself I took my table, added a section break before and a section break after and then set it to two columns and it breaks my table into two and distributes it across the columns. Looking at the layout in the Open XML productivity tool I see it added this before the table:
<w:p w:rsidR="00E634EE" w:rsidRDefault="00E634EE" w14:paraId="0D41C6E2" w14:textId="77777777" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:pPr>
<w:sectPr w:rsidR="00E634EE" w:rsidSect="00C511F2">
<w:pgSz w:w="12240" w:h="15840" />
<w:pgMar w:top="864" w:right="864" w:bottom="1440" w:left="864" w:header="720" w:footer="720" w:gutter="0" />
<w:cols w:space="720" />
<w:docGrid w:linePitch="360" />
</w:sectPr>
</w:pPr>
</w:p>
And after my table it added this:
<w:p w:rsidR="00E634EE" w:rsidP="00E634EE" w:rsidRDefault="00E634EE" w14:paraId="15329047" w14:textId="77777777" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:pPr>
<w:rPr>
<w:noProof />
</w:rPr>
<w:sectPr w:rsidR="00E634EE" w:rsidSect="00E634EE">
<w:type w:val="continuous" />
<w:pgSz w:w="12240" w:h="15840" />
<w:pgMar w:top="864" w:right="864" w:bottom="1440" w:left="864" w:header="720" w:footer="720" w:gutter="0" />
<w:cols w:space="720" w:num="2" />
<w:docGrid w:linePitch="360" />
</w:sectPr>
</w:pPr>
</w:p>
(interestingly the 2 columns are defined in the section break after the table and not before it).
So I edited my code to add section breaks before and after my table and it does produce columns...but my table doesn't break across the columns. Instead it's all stuffed in the left-most column.
So how, and where (if possible) can I indicate how and where to start putting table rows in the second column rather than the first?
These are the breaks that end up in my file:
<w:p w:rsidR="00EA3E62" w:rsidRDefault="003B0473" w14:paraId="6A8C371A" w14:textId="77777777" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:pPr>
<w:sectPr w:rsidR="00EA3E62">
<w:pgSz w:w="12240" w:h="15840" />
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0" />
<w:cols w:space="720" />
<w:docGrid w:linePitch="360" />
</w:sectPr>
</w:pPr>
</w:p>
<w:tbl xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
...
</w:tbl>
<w:p w:rsidR="00EA3E62" w:rsidRDefault="003B0473" w14:paraId="784DE666" w14:textId="77777777" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:pPr>
<w:sectPr w:rsidR="00EA3E62">
<w:type w:val="continuous" />
<w:pgSz w:w="12240" w:h="15840" />
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0" />
<w:cols w:space="720" w:num="2" />
</w:sectPr>
</w:pPr>
</w:p>
Added with (and running through Word Automation Services):
// Insert section breaks
var end = new Paragraph(
new ParagraphProperties(
new SectionProperties(
new SectionType() { Val = SectionMarkValues.Continuous },
new Columns() { Space = "720", ColumnCount = 2, Separator = true })
)
);
parent.InsertAfterSelf(end);
parent.InsertAfterSelf(t);
parent.InsertAfterSelf(new Paragraph(
new ParagraphProperties(
new SectionProperties(
new SectionType() { Val = SectionMarkValues.Continuous })
)
)
);
Where parent is the element I'm adding my table after and t is my Table element.