【问题标题】:OpenXml Word ,, Set RTL text along with font sizeOpenXml Word ,, 设置 RTL 文本和字体大小
【发布时间】:2014-06-23 13:52:23
【问题描述】:

我正在尝试为单词表单元格文本设置字体大小和从右到左的属性 但它总是需要其中一个,每当我同时设置它们时,它只需要 RTL 属性 这是我的代码

Paragraph p = cell.Elements<Paragraph>().First();
        if (p == null || p.Elements<Run>() == null || p.Elements<Run>().ToArray().Length < 1)
            p.Append(new Run());
        Run r = p.Elements<Run>().First();
        RunProperties RP = r.AppendChild(new RunProperties());
        FontSize fontSize = new FontSize();
        fontSize.Val = Fontsize.ToString();
        RP.AppendChild(fontSize);
        RightToLeftText RT = new RightToLeftText()
            {
                Val = new DocumentFormat.OpenXml.OnOffValue(true)
            };
        RP.Append(RT);
        if (r == null || r.Elements<Text>() == null || r.Elements<Text>().ToArray().Length < 1)
            r.Append(new Text());
        Text t = r.Elements<Text>().First();
        t.Text = New.ToString();

这些代码将单元格的文本设置为 RTL 文本,但具有标准字体大小 如果我删除了 rtl 代码,字体大小可以正常工作 我已经尝试并搜索了很多,但没有任何线索 任何提示将不胜感激

提前致谢

【问题讨论】:

    标签: openxml


    【解决方案1】:

    我找到了答案,我需要添加

    FontSizeComplexScript fontSizeComplexScript = new FontSizeComplexScript() { Val = Fontsize.ToString() };
    

    而且效果很好 谢谢你们 请将此标记为已回答

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 2017-12-10
      • 1970-01-01
      • 2013-03-05
      • 2013-10-08
      相关资源
      最近更新 更多