I'm building CSVs via JavaScript and some of the cell values contain hashtags and other special characters. I have noticed in particular that the hashtags act as a hard stop for the file. I have not been able to find a solution online, nor have I really seen this specific issue. I have tried the \uFEFF
fix, but to no avail. Below is the function I use to build my CSVs.
export const buildCSV = (headers, data) => {
if (!headers && !data) return;
let csvContent = "data:text/csv;charset=UTF-8,";
if (headers) {
csvContent += headers.join(",") + "\r\n";
}
if (data) {
data.forEach(row => {
csvContent += row.join(",") + "\r\n";
});
}
return encodeURI(csvContent);
};
For reference, currently, a value such as 150 # content
will show up as 150
and the rest of the rows are cutoff when opening the CSV.
Thank you in advance to anyone that takes the time to provide an answer!