Created
December 25, 2017 08:06
-
-
Save ayhaadam/d1e991e6caeb565a9b5e2d95add3eed3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var csvArray = []; | |
this.exportOrders.forEach(function(order, index) { | |
var csvEntry = [order.id, order.card.from , order.card.to, order.card.content]; | |
csvArray.push(csvEntry); | |
}); | |
// http://papaparse.com | |
var csvString = Papa.unparse({ | |
fields: ['訂單編號', '卡片 From', '卡片 To', '內容'], | |
data: csvArray | |
}); | |
var encodedUri = encodeURI(csvString); | |
var link = document.createElement('a'); | |
link.setAttribute('href', 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodedUri); | |
link.setAttribute('download', '卡片 CSV.csv'); | |
link.click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment