如何将 Crystal Report 导出到 Unicode 文本文件?

发布于 2024-07-08 15:44:43 字数 554 浏览 12 评论 0原文

我正在尝试将 Crystal Report 导出到文本文件,同时保留在其中找到的任何 Unicode 字符。 默认情况下,Crystal Reports 似乎导出为 ANSI 文本文件。

这是我正在做的事情的高度简化版本:

Dim objCRReport As CRAXDRT.Report
[...]
objCRReport.ExportOptions.FormatType = 8 'crEFTText
objCRReport.ExportOptions.DestinationType = 1 'crEDTDiskFile
objCRReport.ExportOptions.DiskFileName = "C:\reportInTextFormat.txt"
objCRReport.Export blnPromptUser 

由于它创建了 ANSI 格式的文件,因此我丢失了在报告中找到的任何特殊字符。 直接查看水晶报表这些字符都没有问题。

请注意,我特别引用了“Crystal Reports 9 ActiveX Designer Runtime Library”。

I'm trying to export a Crystal Report to a text file, while preserving any Unicode characters that are found within. By default, Crystal Reports seems to export to an ANSI text file.

Here is a highly simplified version of what I'm doing:

Dim objCRReport As CRAXDRT.Report
[...]
objCRReport.ExportOptions.FormatType = 8 'crEFTText
objCRReport.ExportOptions.DestinationType = 1 'crEDTDiskFile
objCRReport.ExportOptions.DiskFileName = "C:\reportInTextFormat.txt"
objCRReport.Export blnPromptUser 

Since it creates a file in ANSI format, I lose any special characters that were found within the report. These characters are all fine when you view the Crystal Report directly.

Please note that I am referencing the "Crystal Reports 9 ActiveX Designer Runtime Library" specifically.

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

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

发布评论

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

评论(1

旧梦荧光笔 2024-07-15 15:44:43

我想指出的是,我尝试在导出之前预先创建一个具有相同名称的 Unicode 文件,希望 Crystal 代码能够注意到该文件,并附加到该文件,而不是创建一个 ANSI文件,但不幸的是事实并非如此。

然后我想我可以通过导出到 RTF 文件(保留字符),然后读取该 RTF 的内容(减去格式)来解决这个问题(忍者风格)。 然后我会自己创建一个 Unicode 文本文件,并将 RTF 内容写入其中。 不幸的是,为了实现这一目标,我不得不考虑使用 RichTextBox,但遇到了很多问题。 我认为我在 VB.Net 中会取得更大的成功,但不幸的是我一直使用 VB6 来完成这项任务。

尝试这些方法后,我发现一篇文章似乎表明Crystal Reports 9 支持导出到 Unicode 文本文件,但我还没有看到它的工作原理。 它提到打印引擎支持它,所以我将更深入地查看是否可以调用它,以防 .export 本身不这样做(我对此表示怀疑)。

事实证明水晶 严重依赖打印机驱动程序来支持 Unicode,因此我决定对此进行研究。 事实证明,打印机驱动程序必须支持Unicode,而我的测试环境就是这种情况。 虽然发现这一点很有趣,但它并没有解决我的问题 - 我已经有一个兼容的打印机驱动程序。

所以,最后:经过几天的努力寻找解决方案,我的老板决定是时候减少我们的损失了,我们计划重新设计该功能,而不涉及水晶报表到文本的导出。 然而,我仍然对如何使用 Crystal 导出到 Unicode 文本文件非常感兴趣 - 所以如果您知道如何,请回答。

I want to point out that I've tried pre-creating a Unicode file with the same name prior to the export, hoping the Crystal code would notice the file, and append to it rather than creating an ANSI file, but unfortunately this is not the case.

I then thought I could get around this problem (ninja style) by just exporting to an RTF file (which preserves the characters), then reading the contents of this RTF (minus the formating). I would then create a Unicode text file myself, writing the RTF contents to it. Unfortunately, to achieve this, I had to look into using a RichTextBox, but encountered a slew of problems with that. I think I'd have more success in VB.Net, but unfortunately I'm stuck with VB6 for this task.

After trying those approaches, I found an article that seems to suggest that Crystal Reports 9 supports exporting to a Unicode Text file, but I have yet to see it work. It mentions that the print engine supports it, so I'm going to look deeper to see if I can invoke it, in case the .export isn't doing so itself (which I doubt).

It turns out Crystal relies heavily on the printer driver for Unicode support, so I decided to look into that. Turns out the printer driver had to support Unicode, and this was the case on my test environment. While this was interesting to find out, it didn't solve my problem - I already had a compatible printer driver.

So, finally: after a few days of trying to find a solution to this, my boss decided it was time to cut our losses, and we instead planned for a re-design of the feature, without involving Crystal Report to Text exports. I am still, however, very interested in how to export to a Unicode text file with Crystal - so please do answer if you know how.

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