【问题标题】:Set RTL direction for "Tablecell" or "Table" in OpenXml在 OpenXml 中为“Tablecell”或“Table”设置 RTL 方向
【发布时间】:2021-05-27 21:41:38
【问题描述】:

我想为使用 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 值。

【问题讨论】:

  • 您的目标是哪个版本的 office 以及什么语言?

标签: c# openxml


【解决方案1】:

如果你的表是这样的:

TableRow &gt; TableCell &gt; Paragraph &gt; Run &gt; 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)
        }
    };
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 2016-02-11
    相关资源
    最近更新 更多