Nour Khaled
04/19/2025, 10:13 PMCeligo AI
04/19/2025, 10:13 PMAI generated answer (using internal Slack threads):Based on the conversations, it appears that NetSuite does not natively support the creation of XLSX files using SuiteScript. However, there are workarounds to this limitation. One option is to use third-party libraries such as SheetJS. This library can be downloaded from npm, placed in the file cabinet, and used with SuiteScript as an external library via shim. This allows you to use its functions to create an XLSX file. Here is the link to the library: https://github.com/SheetJS/sheetjs Another option is to create an XML file that is readable by Excel. This can be done by exporting a saved search and formatting the XML in a way that Excel can interpret. Here is a code sample that was provided in the conversation:
javascript
var fileContent = '<?xml version=\"1.0\"?>'
fileContent += '<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"';
fileContent += ' xmlns:o=\"urn:schemas-microsoft-com:office:office\"';
fileContent += ' xmlns:x=\"urn:schemas-microsoft-com:office:excel\"';
fileContent += ' xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"';
fileContent += ' xmlns:html=\"<http://www.w3.org/TR/REC-html40>\">';
fileContent += '<Worksheet ss:Name=\"Orders\">';
fileContent += '<Table>';
//Header
fileContent += '<Row>';
fileContent += '<Cell><Data ss:Type=\"String\">Order #</Data></Cell>';
fileContent += '</Row>';
//Lines
search.load({id: 'customsearch_fs_f16_fr_ups'}).run().each(function(result){
result = JSON.parse(JSON.stringify(result));
fileContent += '<Row>';
fileContent += '<Cell><Data ss:Type=\"String\">' + result.values['GROUP(tranid)'] + '</Data></Cell>';
fileContent += '</Row>';
return true;
});
fileContent += '</Table></Worksheet></Workbook>';
var base64EncodedString = encode.convert({
string: fileContent,
inputEncoding: encode.Encoding.UTF_8,
outputEncoding: encode.Encoding.BASE_64
});
var excelFile = file.create({name: createFileName(), fileType: 'EXCEL', contents: base64EncodedString});
excelFile.folder = [FOLDER_ID];
excelFile.save();
Please note that when using the 'EXCEL' file type, Excel may warn that the file type does not match the content. You can ignore this warning and proceed with opening the file.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/19/2025, 10:14 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840922952
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83965987
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836841106
Celigo AI
04/19/2025, 10:14 PM