如何在使用 suitelet 创建的 excel 文件中传递动态值
How to pass dynamic value in excel file that is created using suitelet
我在 suitelet 中创建了一个 excel 文件。我想在 excel 文件中传递动态值,所以我该怎么做。例如:
我想通过 :
var transaction_id = searchresult.getValue("internalid",'transaction');
在 excel 文件中。
我尝试了下面的方法,但它抛出损坏的文件错误。 *注意:将动态数据传递给文件时,带有静态数据的文件会产生很好的问题。
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);
谢谢
假设您已经将 transaction_id
作为一个变量,并且您已经适当地填充了它,您只需要将两个标记字符串与您的变量连接起来:
'<Cell><Data ss:Type="String">' + transaction_id + '</Data></Cell>' +
我在 suitelet 中创建了一个 excel 文件。我想在 excel 文件中传递动态值,所以我该怎么做。例如: 我想通过 :
var transaction_id = searchresult.getValue("internalid",'transaction');
在 excel 文件中。
我尝试了下面的方法,但它抛出损坏的文件错误。 *注意:将动态数据传递给文件时,带有静态数据的文件会产生很好的问题。
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);
谢谢
假设您已经将 transaction_id
作为一个变量,并且您已经适当地填充了它,您只需要将两个标记字符串与您的变量连接起来:
'<Cell><Data ss:Type="String">' + transaction_id + '</Data></Cell>' +