从 Office 选择中获取 HTML

发布于 2024-09-26 14:41:16 字数 493 浏览 1 评论 0原文

我正在开发一个项目,为 Excel、Word、Powerpoint 和 Outlook 创建 Office 插件。我有一个按钮,应该可以获取用户选择的任何内容并将其导入所见即所得编辑器中。现在这就是我获取选择并提取 html 的方式。

Excel.Worksheet sheet = excelApp.ActiveSheet;
excelApp.ActiveWindow.RangeSelection.Copy();
if (Clipboard.ContainsText(TextDataFormat.Html))
   html = (Clipboard.GetData(DataFormats.Html).ToString());

然后我对 html 进行了一些修改,以消除它给我带来的所有额外垃圾。问题是,如果突出显示非 ASCII 符号,例如 こんにちは,则返回的 html 在其位置包含不正确的数据。任何想法将不胜感激。 (我对 Word 也有类似的问题,所以请告诉我任何想法!) 谢谢, 菲尔

I'm working on a project where I have created Office Addin's for Excel, Word, Powerpoint and Outlook. I have a button that is supposed to get the get the whatever the user has selected and import it into a WYSIWYG editor. For now this is how I get the selection and extract html.

Excel.Worksheet sheet = excelApp.ActiveSheet;
excelApp.ActiveWindow.RangeSelection.Copy();
if (Clipboard.ContainsText(TextDataFormat.Html))
   html = (Clipboard.GetData(DataFormats.Html).ToString());

Then I modify the html a bit to get rid of all the extra garbage it gives me. The issue is that if non-ASCII symbols are highlighted, for example こんにちは, then the returned html contains incorrect data in it's place. Any idea's would be greatly appreciated.
(I have similar issues with Word so let me know of any ideas for that!)
Thanks,
Phil

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

够钟 2024-10-03 14:41:16

您需要更改为 DataFormats.UnicodeText。这些是多字节字符。

You need to change to DataFormats.UnicodeText. Those are multi-byte characters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文