<p>Ok so I found this really well documented <code>node_module</code> called <a href="https://github.com/SheetJS/js-xlsx" rel="noopener nofollow ugc">js-xlsx</a></p>
<p><strong>Question :</strong> How can I <strong>parse an xlsx to output json</strong>?</p>
<p>Here is what the excel sheet looks like:</p>
<p>In the end the json should look like this:</p>
<pre><code class="lang-auto">[
{
"id": 1,
"Headline": "Team: Sally Pearson",
"Location": "Austrailia",
"BodyText": "...",
"Media: "..."
},
{
"id": 2,
"Headline": "Team: Rebeca Andrade",
"Location": "Brazil",
"BodyText": "...",
"Media: "..."
}
]
</code></pre>
<p><strong>index.js:</strong></p>
<pre><code class="lang-auto">if(typeof require !== 'undefined') {
console.log('hey');
XLSX = require('xlsx');
}
var workbook = XLSX.readFile('./assets/visa.xlsx');
var sheet_name_list = workbook.SheetNames;
sheet_name_list.forEach(function(y) { /* iterate through sheets /
var worksheet = workbook.Sheets[y];
for (z in worksheet) {
/ all keys that do not begin with "!" correspond to cell addresses */
if(z[0] === '!') continue;
// console.log(y + "!" + z + "=" + JSON.stringify(worksheet[z].v));
}
});
XLSX.writeFile(workbook, 'out.xlsx');
</code></pre>