I’m writing to a CSV file in Node.js and I’d like to add a hyperlink to some of the fields, as the =HYPERLINK
function can be recognized by excel and some other spreadsheet apps.
So for example, I have this function
const addHyperlink = (url, str) => `=HYPERLINK("${url}", "${str}")`;
And the function is used as follows:
const processToCSVFormat = () => {
...
return `${author}, ${date}, ${addHyperlink(purchaseURL, title)}, ...`
}
The issue is of course that when the CSV is parsed in excel, it picks up the comma and separates the function into the next column, like
Column 1 | =HYPERLINK("https://google.com" | "Google") | Column 4 | Column 5 | ...
I know that the comma needs to be escaped, but I’ve been unable to get it working looking at past answers – I may be doing it incorrectly though. I tried:
return ${author}, ${date}, "${addHyperlink(purchaseURL, title)}", ...
Thanks!