是否可以強制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?
「其他文章」