HTML 字符串编码

本文关键字:编码 字符串 HTML | 更新日期: 2023-09-27 18:33:33

我要求在不使用 introp dll 的情况下从 C# 导出 ppt。我能够做到这一点,但是当我附加一些 HTML 字符串时,即 "<b>Krishna</b><br/><strong>Ram</strong>"在任何幻灯片中,它显示的是相同的文本,而不是呈现的文本。有什么能帮我吗?

HTML 字符串编码

PPT目前似乎不支持直接在PPT中呈现HTML。 您必须将幻灯片导出为 HTML,或使用内置格式,如回答以下问题:以编程方式将字体格式应用于 PowerPoint 文本。

Set tr = ActiveWindow.Selection.SlideRange.Shapes(1).TextFrame.TextRange
        With tr
            .Text = "Hi There Buddy!"
            .Words(1).Font.Bold = msoTrue

有关 C# 和 Office 2010 中设置的了解,请参阅字体成员。

你应该能够自己测试我的断言,通过使用HttpServerUtility.HtmlEncode方法对文本进行HTML编码:

String TestString = "This is a <Test String>.";

String EncodedString = Server.HtmlEncode(TestString);