Set RTL direction for "Tablecell" or "Table" in OpenXml
I want to set a RTL direction for some cell of a table that I create with OpenXml.
row.Append(
new TableCell(
new Paragraph(
new Run(
new Text("FullName")))){
TableCellProperties = new TableCellProperties()
{
TableCellWidth = new TableCellWidth(){
Type = TableWidthUnitValues.Dxa,
Width = "3400" },
TextDirection = new TextDirec开发者_C百科tion(){
Val = new EnumValue<TextDirectionValues>(TextDirectionValues.TopToBottomRightToLeft)}
}
});
I wrote this code, but TextDirectionValues Enum dosen't have a RTL value.
If your tables are like this:
TableRow > TableCell > Paragraph > Run > Text.
This code may help you:
//Justification
aRow.Descendants<TableCell>().ElementAt(indx).Descendants<Paragraph>()
.ElementAt(0).ParagraphProperties = new ParagraphProperties()
{
Justification = new Justification()
{
Val = new EnumValue<JustificationValues>(JustificationValues.Right)
}
};
//RightToLeftText
foreach (var r in aRow.Descendants<TableCell>().ElementAt(indx).Descendants<Run>())
{
r.RunProperties = new RunProperties()
{
RightToLeftText = new RightToLeftText()
{
Val = new OnOffValue(true)
}
};
}
精彩评论