I have created an excel file in suitelet. I want to pass dynamic value in the excel file so How can i do that. For Eg: I want to pass :
var transaction_id = searchresult.getValue("internalid",'transaction');
in the excel File.
I tried the below method but its throwing Corrupted file error. *Note : File with static data is generated fine problem while passing the dynamic data to 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='sheet_name'>';
//Below mention is the place(transaction_id) where I want to pass the dynamic value
xmlStr += '<Table>' +
'<Row>' +
'<Cell><Data ss:Type="String">transaction_id</Data></Cell>' +
'</Row>';
xmlStr += '</Table></Worksheet></Workbook>';
var xlsFile = nlapiCreateFile('sheet_name.xls', 'EXCEL', nlapiEncrypt(xmlStr, 'base64'));
xlsFile.setFolder(6157);
var fileID = nlapiSubmitFile(xlsFile);
Thanks
Assuming you already have
transaction_id
as a variable, and you've populated it appropriately, you'll just need to concatenate the two tag strings with your variable: