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.
我正在尝试将Crystal Report导出到文本文件,同时保留在其中找到的任何Unicode字符。默认情况下,Crystal Reports似乎导出为ANSI文本文件。
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.
由于它以ANSI格式创建文件,因此我丢失了在报告中找到的任何特殊字符。直接查看Crystal Report时,这些字符都很好。
Please note that I am referencing the "Crystal Reports 9 ActiveX Designer Runtime Library" specifically.
请注意,我特别引用了“Crystal Reports 9 ActiveX Designer运行时库”。
1 个解决方案
#1
1
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.
我想指出,我已经尝试在导出之前预先创建一个具有相同名称的Unicode文件,希望Crystal代码会注意到该文件,并附加到它而不是创建ANSI文件,但不幸的是,这不是案子。
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.
然后我想我可以通过导出到RTF文件(保留字符)来解决这个问题(忍者风格),然后读取此RTF的内容(减去格式化)。然后我会自己创建一个Unicode文本文件,将RTF内容写入其中。不幸的是,要实现这一点,我不得不考虑使用RichTextBox,但遇到了一些问题。我想我在VB.Net上有更多的成功,但不幸的是我为了这个任务而坚持使用VB6。
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).
尝试这些方法后,我发现一篇文章似乎表明Crystal Reports 9支持导出到Unicode文本文件,但我还没有看到它的工作原理。它提到打印引擎支持它,所以我会更深入地看看我是否可以调用它,以防.export本身没有这样做(我怀疑)。
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.
事实证明,Crystal在很大程度上依赖于支持Unicode的打印机驱动程序,所以我决定调查一下。原来打印机驱动程序必须支持Unicode,在我的测试环境中就是这种情况。虽然这很有趣,但它并没有解决我的问题 - 我已经有了兼容的打印机驱动程序。
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.
所以,最后:经过几天试图找到解决方案后,我的老板决定是时候减少损失了,而我们计划重新设计该功能,而不涉及Crystal Report to Text导出。但是,我仍然对如何使用Crystal导出到Unicode文本文件非常感兴趣 - 所以如果你知道如何请回答。
#1
1
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.
我想指出,我已经尝试在导出之前预先创建一个具有相同名称的Unicode文件,希望Crystal代码会注意到该文件,并附加到它而不是创建ANSI文件,但不幸的是,这不是案子。
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.
然后我想我可以通过导出到RTF文件(保留字符)来解决这个问题(忍者风格),然后读取此RTF的内容(减去格式化)。然后我会自己创建一个Unicode文本文件,将RTF内容写入其中。不幸的是,要实现这一点,我不得不考虑使用RichTextBox,但遇到了一些问题。我想我在VB.Net上有更多的成功,但不幸的是我为了这个任务而坚持使用VB6。
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).
尝试这些方法后,我发现一篇文章似乎表明Crystal Reports 9支持导出到Unicode文本文件,但我还没有看到它的工作原理。它提到打印引擎支持它,所以我会更深入地看看我是否可以调用它,以防.export本身没有这样做(我怀疑)。
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.
事实证明,Crystal在很大程度上依赖于支持Unicode的打印机驱动程序,所以我决定调查一下。原来打印机驱动程序必须支持Unicode,在我的测试环境中就是这种情况。虽然这很有趣,但它并没有解决我的问题 - 我已经有了兼容的打印机驱动程序。
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.
所以,最后:经过几天试图找到解决方案后,我的老板决定是时候减少损失了,而我们计划重新设计该功能,而不涉及Crystal Report to Text导出。但是,我仍然对如何使用Crystal导出到Unicode文本文件非常感兴趣 - 所以如果你知道如何请回答。