如何使用openxml.wordprocessing

时间:2019-04-04 21:51:45

标签: c# openxml

我正在创建具有从右到左表格的新文档。如何将表格方向设置为RTL?

我尝试了以下代码,但没有用:

             Table tb = new Table(new TableLayout() { Type = TableLayoutValues.Autofit });
            tb.Append( new TableProperties(new TextDirection() { Val=TextDirectionValues.TopToBottomRightToLeft}, new RightToLeftText() { Val =new DocumentFormat.OpenXml.OnOffValue(true) }, new TableBorders(new TopBorder { Val = new DocumentFormat.OpenXml.EnumValue<BorderValues>(BorderValues.BasicThinLines), Size = 5 }, new BottomBorder { Val = new DocumentFormat.OpenXml.EnumValue<BorderValues>(BorderValues.BasicThinLines), Size = 5 }, new LeftBorder { Val = new DocumentFormat.OpenXml.EnumValue<BorderValues>(BorderValues.BasicThinLines), Size = 5 }, new RightBorder { Val = new DocumentFormat.OpenXml.EnumValue<BorderValues>(BorderValues.BasicThinLines), Size = 5 }, new InsideHorizontalBorder { Val = new DocumentFormat.OpenXml.EnumValue<BorderValues>(BorderValues.BasicThinLines), Size = 5 }, new InsideVerticalBorder { Val = new DocumentFormat.OpenXml.EnumValue<BorderValues>(BorderValues.BasicThinLines), Size = 5 }))); 

1 个答案:

答案 0 :(得分:1)

TableProperties tblProp = new TableProperties();
tblProp.BiDiVisual = new BiDiVisual { Val = new EnumValue<OnOffOnlyValues> { Value = OnOffOnlyValues.On } };