从 Office 选择中获取 HTML
我正在开发一个项目,为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要更改为 DataFormats.UnicodeText。这些是多字节字符。
You need to change to DataFormats.UnicodeText. Those are multi-byte characters.