Reputation: 5299
I Word document i have a two tables. I fill it with data using OpenXML
:
var firstTable = (mainPart.Document.Body.Descendants<Table>().ToList())[1];
var firstTableRows = firstTable.ChildElements.OfType<TableRow>().ToArray();
var firstTableRowСells = firstTableRows[0].ChildElements.OfType<TableCell>().ToArray();
var secondTable = (mainPart.Document.Body.Descendants<Table>().ToList())[2];
var secondTableRows = secondTable.ChildElements.OfType<TableRow>().ToArray();
var secondTableRowСells = secondTableRows[0].ChildElements.OfType<TableCell>().ToArray();
firstTableRowСells[0].ChildElements.First<Paragraph>().ChildElements.First<Run>().ChildElements.First<Text>().Text = firstString;
secondTableRowСells[0].ChildElements.First<Paragraph>().ChildElements.First<Run>().ChildElements.First<Text>().Text = secondString;
Strings what i put into tables may have a different length so it's causes the that rows have a different height. But i want that same rows in tables have a same height. It's mean: if firstString.Lenght>secondString.Lenght
i want set row's height in secondTable like row's height in firstTable.
And if secondString.Lenght>firstString.Lenght
i want set row's height in firstTable like row's height in secondTable.
It's possible?
Upvotes: 0
Views: 7552
Reputation: 5102
TableRow row = new TableRow(
new TableRowProperties(
new TableRowHeight() {Val = Convert.toUInt32("20")}));
Upvotes: 3