Has someone created an xlsx file using file.create...
# suitescript
j
Has someone created an xlsx file using file.create? If so, how did you generate the file and save?
b
your only hope in suitescript is getting sheet.js to work
j
Trying but it doesn't save file correctly
b
you will need to be more specific than that
j
ar wb = xlsx.utils.book_new();        wb.Props = {         Title: fileName,         Subject: fileName,         Author: "",         CreatedDate: new Date()        };        wb.SheetNames.push("Sheet1");        var ws = xlsx.utils.aoa_to_sheet(rows);        wb.Sheets[fileName] = ws;        //var wbout = XLSX.write(wb, {bookType:'xlsx',  type: 'binary'});        /*        const result = xlsx.write(wb, {         BookType:'xlsx', // output file type         Type:'buffer', // data type of output         Compression: true // turn on zip compression         });*/           //var result = xlsx.write(wb, {bookType:"xlsx", type:'base64'});         //var result = xlsx.write(wb, {bookType:"xlsx", type:'binary'});         var result = xlsx.write(wb);         var fileObj = file.create({             name: fileName + '-' + dateString + '.xlsx',             fileType: file.Type.EXCEL,             contents: result,             folder: netsuiteFolder         });
b
what error ar you getting
j
files generate but they don't open in excel
data looks incorrect
maybe something with the xlsx.write function
b
excel files are treated as binary
the contents need to be base 64 encoded
j
yes, I finally got it to work
as xls anyway.. I wasn't adding the sheet correctly as you can see in my code
thanks for your help
xlsx doesn't work whenusing fileType EXCEL