Skip to content

Instantly share code, notes, and snippets.

@bilashcse
Last active February 10, 2019 19:13
Show Gist options
  • Save bilashcse/acac3710d1495d8bc493f1bdbc52cbdb to your computer and use it in GitHub Desktop.
Save bilashcse/acac3710d1495d8bc493f1bdbc52cbdb to your computer and use it in GitHub Desktop.
Initial zero supported Mobile/ Phone Numbers CSV download front-end hack with Unicode supports
let csvContent = "data:application/vnd.ms-excel;charset=utf-8,\uFEFF";
let csvArray = [
[
"Id",
"Name",
"Phone"
]
];
usersArray.forEach(user => {
csvArray.push([
user.id,
user.name,
"=\"" + user.phone + "\""
]);
});
csvArray.forEach(infoArray => {
let dataString = infoArray.join(",");
csvContent = csvContent + dataString + "\n";
})
let encodedUri = encodeURI(csvContent);
let link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "download-user-info.csv");
document.body.appendChild(link);
link.click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment