我想为使用OpenXml创建的表格的某个单元格设置RTL方向。
row.Append(
new TableCell(
new Paragraph(
new Run(
new Text("FullName")))){
TableCellProperties = new TableCellProperties()
{
TableCellWidth = new TableCellWidth(){
Type = TableWidthUnitValues.Dxa,
Width = "3400" },
TextDirection = new TextDirection(){
Val = new EnumValue<TextDirectionValues>(TextDirectionValues.TopToBottomRightToLeft)}
}
});
我编写了这段代码,但TextDirectionValues Enum没有RTL值。
答案 0 :(得分:3)
如果您的表格如下:
TableRow > TableCell > Paragraph > Run > Text.
此代码可以帮助您:
//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)
}
};
}