Javascript to csv export encoding issue

前端 未结 8 1364
Happy的楠姐
Happy的楠姐 2020-11-29 00:33

I need to export javascript array to excel file and download it I\'m doing it in this code. data is a javascript object array.

var csvContent = \"data:t         


        
8条回答
  •  一整个雨季
    2020-11-29 01:02

    You should add the UTF-8 BOM at the start of the text, like:

    var csvContent = "data:text/csv;charset=utf-8,%EF%BB%BF";
    

    It worked for me with Excel 2013.

    Demo Fiddle

提交回复
热议问题