Netsuite: Help needed to add in style when creating Excel File using SuitesScript

723 views Asked by At

I wish to create an Excel file using SuiteScript. It works fine. But whenever I tried to add in Style the file will be corrupted.

Is there any ways to add in Style? I suspect the part where we encoded the data into base 64 that causing the problem.

Still, any advise on this?

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 += '<Styles>';
       +'<Style ss:ID=”s1”>' 
       + '<Font ss:Bold=”1" ss:Underline=”Single”/>'
       + '</Style>' + '</Styles>';

xmlStr += '<Worksheet ss:Name="Sheet1">';
xmlStr += '<Table>' +
'<Row>' +
'<Cell ss:StyleID="s1"><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 += '</Table></Worksheet></Workbook>';

var xlsFile = nlapiCreateFile('sample.xls', 'EXCEL', nlapiEncrypt(xmlStr, 'base64'));

xlsFile.setFolder('< folderid >');

var fileID = nlapiSubmitFile(xlsFile);
1

There are 1 answers

2
bknights On BEST ANSWER

You have used fancy quotes around your attributes. That is not valid XML e.g. ”Single” should be "Single"