是否可以强制Excel自动识别UTF-8 CSV文件? - Is it possible to force Excel recognize UTF-8 CSV files automatically?

语言: CN / TW / HK

问题:

I'm developing a part of an application that's responsible for exporting some data into CSV files.我正在开发应用程序的一部分,该应用程序负责将一些数据导出到CSV文件中。 The application always uses UTF-8 because of its multilingual nature at all levels.该应用程序始终使用UTF-8,因为它在所有级别上都具有多语言的性质。 But opening such CSV files (containing eg diacritics, cyrillic letters, Greek letters) in Excel does not achieve the expected results showing something like Г„/Г¤, Г–/Г¶ .但是,在Excel中打开此类CSV文件(包含变音符号,西里尔字母,希腊字母)并不能获得预期的结果,例如Г„/Г¤, Г–/Г¶ And I don't know how to force Excel understand that the open CSV file is encoded in UTF-8.而且我不知道如何强制Excel理解打开的CSV文件是以UTF-8编码的。 I also tried specifying UTF-8 BOM EF BB BF , but Excel ignores that.我还尝试指定UTF-8 BOM EF BB BF ,但Excel忽略了这一点。

Is there any workaround?有什么解决方法吗?

PS Which tools may potentially behave like Excel does? PS哪些工具的行为可能类似于Excel?


UPDATE更新

I have to say that I've confused the community with the formulation of the question.我必须说,我已经使社区与问题的表达混淆了。 When I was asking this question, I asked for a way of opening a UTF-8 CSV file in Excel without any problems for a user, in a fluent and transparent way.当我问这个问题时,我想以一种流畅,透明的方式在Excel中打开一个UTF-8 CSV文件而对用户没有任何问题的方法。 However, I used a wrong formulation asking for doing it automatically .但是,我使用了错误的表述,要求自动执行 That is very confusing and it clashes with VBA macro automation.这非常令人困惑,并且与VBA宏自动化相冲突。 There are two answers for this questions that I appreciate the most: the very first answer by Alex https://stackoverflow.com/a/6002338/166589 , and I've accepted this answer;对于这个问题,有两个答案是我最感激的:Alex的第一个答案https://stackoverflow.com/a/6002338/166589 ,我已经接受了这个答案; and the second one by Mark https://stackoverflow.com/a/6488070/166589 that have appeared a little later.马克(Mark https://stackoverflow.com/a/6488070/166589)的第二个版本则在不久后出现。 From the usability point of view, Excel seemed to have lack of a good user-friendly UTF-8 CSV support, so I consider both answers are correct, and I have accepted Alex's answer first because it really stated that Excel was not able to do that transparently.从可用性的角度来看,Excel似乎缺乏对用户友好的UTF-8 CSV的良好支持,因此我认为这两个答案都是正确的,并且我首先接受了Alex的答案,因为它确实表明Excel无法做到这一点。透明地That is what I confused with automatically here.这就是我在这里自动感到困惑的地方。 Mark's answer promotes a more complicated way for more advanced users to achieve the expected result.马克的答案为更高级的用户提供了一种更复杂的方式来达到预期的结果。 Both answers are great, but Alex's one fits my not clearly specified question a little better.这两个答案都很好,但是亚历克斯的答案更适合我未明确说明的问题。


UPDATE 2更新2

Five months later after the last edit, I've noticed that Alex's answer has disappeared for some reason.在上次编辑五个月后,我注意到亚历克斯的答案由于某种原因而消失了。 I really hope it wasn't a technical issue and I hope there is no more discussion on which answer is greater now.我真的希望这不是一个技术问题,我希望现在不再讨论哪个答案更大。 So I'm accepting Mark's answer as the best one.因此,我接受马克的回答为最佳答案。


解决方案:

参考一: https://stackoom.com/question/PBSa
参考二: Is it possible to force Excel recognize UTF-8 CSV files automatically?
「其他文章」