Use the following sample code to create an XLS file in NetSuite’s Suitelet.
// XML content of the file var xmlStr = '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>'; xmlStr += '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" '; xmlStr += 'xmlns:o="urn:schemas-microsoft-com:office:office" '; xmlStr += 'xmlns:x="urn:schemas-microsoft-com:office:excel" '; xmlStr += 'xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" '; xmlStr += 'xmlns:html="http://www.w3.org/TR/REC-html40">'; xmlStr += '<Worksheet ss:Name="Sheet1">'; xmlStr += '<Table>' + '<Row>' + '<Cell><Data ss:Type="String"> Folio3 Pvt. Ltd </Data></Cell>' + '<Cell><Data ss:Type="String"> Products </Data></Cell>' + '</Row>'; xmlStr += '<Row>' + '<Cell><Data ss:Type="String">1</Data></Cell>' + '<Cell><Data ss:Type="String">NetSuite EBay Connector</Data></Cell>' + '</Row>'; xmlStr += '<Row>' + '<Cell><Data ss:Type="String">2</Data></Cell>' + '<Cell><Data ss:Type="String">NetSuite Magento Connector</Data></Cell>' + '</Row>'; xmlStr += '<Row>' + '<Cell><Data ss:Type="String">3</Data></Cell>' + '<Cell><Data ss:Type="String">NetSuite Salesforce Connector</Data></Cell>' + '</Row>'; xmlStr += '<Row>' + '<Cell><Data ss:Type="String">4</Data></Cell>' + '<Cell><Data ss:Type="String">Smart Database Connector</Data></Cell>' + '</Row>'; xmlStr += '<Row>' + '<Cell><Data ss:Type="String">5</Data></Cell>' + '<Cell><Data ss:Type="String">NetSuite EBay Motors Connector</Data></Cell>' + '</Row>'; xmlStr += '</Table></Worksheet></Workbook>'; //create file var xlsFile = nlapiCreateFile('sample.xls', 'EXCEL', nlapiEncrypt(xmlStr, 'base64')); // folder id in which the file file will be saved xlsFile.setFolder('< folderid >'); //save file var fileID = nlapiSubmitFile(xlsFile);