โ02-12-2021 03:42 PM
Hey Everyone! I'm new to Workato and wanted to see if anyone has solved for the ability to split larger Excel workbooks into singular CSV's to use the utility Workato CSV Parser action? Or if anyone has some pro tips on tackling large excel workbooks, I'm all ears!!
โ04-02-2021 09:22 PM
Will the Javascript also work to CREATE an excel from CSV?
โ04-02-2021 10:02 PM
It appears so. It supports reading a CSV and then writing a XSLX:
https://www.npmjs.com/package/exceljs#file-io
Iโll give it a try, and weโll see. Iโll post my results here with a guide that you can use for doing the same.
โ04-03-2021 02:09 AM
Hello Manuel,
Following the attached guide, I was able to create a script that uses the exceljs library to convert from a CSV file string to an Excel spreadsheet. Unfortunately, our Javascript action does not support a file/binary output type, and when using a string output I believed itโs converting the Excel spreadsheet to UTF-8 encoding. Thatโs a problem because the Excel spreadsheet is actually a zipped folder, and converting to UTF-8 corrupts the file. Iโm not sure thereโs a way around this, but Iโll continue to explore.
Hereโs the script I used with the example:
constExcel =require('exceljs');
const {Readable } =require('stream');
constmyFunction =async (input)=> {
constoutput = {};
conststream =Readable.from(input.string_in);
constworkbook =newExcel.Workbook();
constworksheet =awaitworkbook.csv.read(stream);
constbuffer =awaitworkbook.xlsx.writeBuffer();
output.string_out = buffer.toString('binary');
console.log(output.string_out);
returnoutput;
}
exports.main = async (input)=> {
returnawaitmyFunction(input);
}
Regards,
โ04-03-2021 01:08 PM
Thanks a lot! I will give it a try!