Ruby: How to generate CSV files that has Excel-friendly encoding

后端 未结 4 1026
暗喜
暗喜 2020-12-30 03:01

I am generating CSV files that needs to be opened and reviewed in Excel once they have been generated. It seems that Excel requires a different encoding than UTF-8.

4条回答
  •  囚心锁ツ
    2020-12-30 03:33

    config = {
    
      encoding: 'ISO-8859-1'
    }
    
    CSV.generate(config) { |csv|  csv << ["Text á", "Text é", "Text æ"] }
    

提交回复
热议问题