Page 1 of 1
Convert Excel File to JSON / CSV
Posted: Mon Jun 22, 2020 2:44 pm
by kodurivp
Hi,
Working on file upload widget. Uploaded the xlsx file, trying to convert xlsx file to csv( for that trying to convert xlsx file to json first). Is there any way or properties to handle this scenario?
Please let me know If you have any questions.
Thanks
Re: Convert Excel File to JSON / CSV
Posted: Tue Jun 23, 2020 4:02 pm
by Scott Klement
Converting an XLSX to CSV is a non-trivial task. We have nothing like that built-in to Genie, but I do have some ideas that might interest you:
1. You could write a program that uses a tool like POI to convert the Excel document.
2. XLSX documents are zip files that contain a bunch of different XML files as well as stuff like images, etc (if any were used). You could unzip it and read the XLSX file yourself in your program.
Good luck
Re: Convert Excel File to JSON / CSV
Posted: Tue Jun 23, 2020 4:21 pm
by Alex
I would look into using Profound.js, along with npm packages like 'xlsx' and/or 'node-xlsx' to accomplish this.
From some of the online posts I am seeing, it could be as simple as:
Code: Select all
const XLSX = require('xlsx');
const workBook = XLSX.readFile(inputFilename);
XLSX.writeFile(workBook, outputFilename, { bookType: "csv" });
But it depends on your needs. I am not sure if one of these packages will do the trick or not.