c# - 如何使用 openxml.wordprocessing 设置 "table direction"

标签 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 }))); 

最佳答案

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

关于c# - 如何使用 openxml.wordprocessing 设置 "table direction",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55525456/

相关文章:

c# - 在不知道元素类型的情况下将项目添加到列表中

c# - 绑定(bind)到 TreeView 选定项

c# - 如何在 C# 中读取用户的十进制数?

c# - 从 C# 程序中反序列化 JSON 时,我是否需要使用 JavaScriptSerializer 以外的任何东西?

openxml-sdk - Open XML SDK v2 究竟负责哪些您在使用 XML 库进行手动编码时必须手动执行的操作?

c# - IIS使用OpenXML创建的word文件处置后继续被IIS锁定

c# - 如何使用 OpenXml 从 xlsx 文件中提取文本

使用 JSON.Net 的 C# JSON 字符串反序列化

java - 在 Docx4j 生成的 Word 文档的页眉中显示图像

c# - OpenXML 中的制表符