I am using the following code that was found on the Suite Answers page to create an Excel file in Suitescript.
I've tried various ways of inserting the data that is generated through a loop of customer records and each time the spreadsheet that is create contains the entire xmlString in Cell A1 of the spreadsheet.
Could anyone give me some guidance.
Thanks in advance.
//construct xml equivalent of the file var xmlString = '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>'; xmlString += '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" '; xmlString += 'xmlns:o="urn:schemas-microsoft-com:office:office" '; xmlString += 'xmlns:x="urn:schemas-microsoft-com:office:excel" '; xmlString += 'xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" '; xmlString += 'xmlns:html="http://www.w3.org/TR/REC-html40">'; xmlString += '<Worksheet ss:Name="Sheet1">'; xmlString += '<Table>' + '<Row>' + '<Cell><Data ss:Type="String"> First Header </Data></Cell>' + '<Cell><Data ss:Type="String"> Second Header </Data></Cell>' + '<Cell><Data ss:Type="String"> Third Header </Data></Cell>' + '<Cell><Data ss:Type="String"> Fourth Header </Data></Cell>' + '<Cell><Data ss:Type="String"> Fifth Header </Data></Cell>' + '</Row>'; xmlString += '<Row>' + '<Cell><Data ss:Type="String">Row 1 Column 1</Data></Cell>' + '<Cell><Data ss:Type="String">Row 1 Column 2</Data></Cell>' + '<Cell><Data ss:Type="String">Row 1 Column 3</Data></Cell>' + '<Cell><Data ss:Type="String">Row 1 Column 4</Data></Cell>' + '<Cell><Data ss:Type="String">Row 1 Column 5</Data></Cell>' + '</Row>'; xmlString += '<Row>' + '<Cell><Data ss:Type="String">Row 2 Column 1</Data></Cell>' + '<Cell><Data ss:Type="String">Row 2 Column 2</Data></Cell>' + '<Cell><Data ss:Type="String">Row 2 Column 3</Data></Cell>' + '<Cell><Data ss:Type="String">Row 2 Column 4</Data></Cell>' + '<Cell><Data ss:Type="String">Row 2 Column 5</Data></Cell>' + '</Row>'; xmlString += '</Table></Worksheet></Workbook></xml>'; //create file var xlsFile = nlapiCreateFile('TEST.xls', 'EXCEL', nlapiEncrypt(xmlString, 'base64')); xlsFile.setFolder(445); //save file var fileID = nlapiSubmitFile(xlsFile);