导出后Word中出现无法读取的字符

发布于 2024-08-17 04:15:26 字数 786 浏览 2 评论 0原文

我有一个 asp.net 页面,它将一些数据导出到 Microsoft Word 2003。数据的来源是用户在输入页面上的 ajax 控件工具包 HtmlEditor 中键入的内容。除非用户将 Word 文档中的文本粘贴到 HtmlEditor 中,否则一切正常。

从 Word 复制的 html 看起来像这样:

<p class="MsoBodyText" style="margin: 0in 0in 0pt"><font color="#000000"><br />\r\nThe Blah Blah Blah of Southern California’s blah blah qualify for a blah of “Rating” with a “hold” status.&nbsp;</font></p>

当内容在 Word 中呈现时,它看起来像这样:

The Blah Blah Blah of Southern California’s blah blah qualify for a blah of “Rating†with a “hold†status.

对此有任何帮助吗?当我将 HTML 强制放入 div 并将其显示在页面上时,我没有问题。只有导出到Word 时才会出现混乱。无论我将 Word 文本直接粘贴到 HtmlEditor 还是使用从 MS Word 粘贴(带清理)按钮,都会发生这种情况。

谢谢。安德鲁.

I have an asp.net page that exports some data to Microsoft Word 2003. The source of the data is what users have typed into an ajax control toolkit HtmlEditor on an input page. All works well unless the user has pasted text from a Word document into the HtmlEditor.

The html that is copied from Word looks like this:

<p class="MsoBodyText" style="margin: 0in 0in 0pt"><font color="#000000"><br />\r\nThe Blah Blah Blah of Southern California’s blah blah qualify for a blah of “Rating” with a “hold” status. </font></p>

When the content is rendered in Word, it looks like this:

The Blah Blah Blah of Southern California’s blah blah qualify for a blah of “Rating†with a “hold†status.

Any help on this? I have no problem when I force the HTML into a div and show it on the page. It's only on the export to Word that it gets messed up. This happens whether I paste the Word text right into the HtmlEditor or use the Paste From MS Word (with cleanup) button.

Thanks. Andrew.

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

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

发布评论

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

评论(2

彡翼 2024-08-24 04:15:26

这是一个文本编码问题,你的“从Word复制的html”是错误的。您使用了单引号和双引号(ASCII 字符 39 和 34,或分别为十六进制 0x27 和 0x22),而 Word 使用智能引号。在 Word 和 HTMLEditor 之间复制和粘贴期间,它们会出现乱码,然后在粘贴回 Word 时显示为错误的字符编码。

如果您保存 HTML 编辑器中的文本并使用十六进制查看器查看它,您将立即发现问题。

我无法帮助您使用“ajax control HTMLEditor”并重新配置它来解决此问题,因为我不熟悉它。

This is a text encoding problem, and your "html that is copied from Word" is wrong. You've used single and double quotes (ASCII characters 39 and 34, or hex 0x27 and 0x22 respectively), while Word is using smart quotes. They're getting garbled during the copy and paste between Word and the HTMLEditor, and then appearing as the wrong character encoding when pasted back to Word.

If you save the text from the HTMLEditor and look at it with a hex viewer, you'll see the problem immediately.

I can't help you with the "ajax control HTMLEditor" and reconfiguring it to fix this, as I'm not familiar with it.

断爱 2024-08-24 04:15:26

我从未想过我会读到“将一些数据导出到 Microsoft Word”这句话。失败。

您的程序正在以编程方式创建 Word 文档,对吗?看起来单引号和双引号上有二进制错误。您如何创建 Word 文档?互操作库?

I never thought I would ever read the phrase "exports some data to Microsoft Word". Fail.

Your program is creating the Word doc programmatically, correct? It looks like you have a binary error on single quotes and double-quotes. How are you creating the Word doc? Interop library?

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