Not able to download resource reports (pivot table) in excel format from portal (Utah)

Jude8
Tera Contributor

Hi All,

 

We have a custom widget , where we added a download button to export Allocation details , Availability report as excel . After utah upgrade , the download button not working. It is download null value in the excel.

in the console when i add log for table i get this error "Value of table is null"

Adding the widget script for reference . Please help me with solution.

 

HTML-->

 

<div>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

 

<div><button id="btnExport" onclick="tableToExcel('pivotTable','pivotTable');">

 

<span class="glyphicon glyphicon-download"></span> Download</button>
<iframe id="txtArea1" style="display:none"></iframe>
</div>
<div>
<iframe id="root_cause_analysis" style="overflow: hidden; height: 90vh; width: 110%;"
ng-src="{{data.src}}" width="100%" hight="100%" frameBorder="0" id="ticketframe" allowfullscreen></iframe>
</div>

 


<div>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
var tableToExcel = (function () {
console.log('button is clicked - ');

var uri = 'data&colon;application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }

return function (table, name) {
if (!table.nodeType) {
table = document.getElementById("pivotTable");
//table = document.getElementById("pivotTable");
console.log('Value of table is '+table);
}
var ctx = { worksheet: "Excel Report" || 'Worksheet', table: table }
var a = document.createElement('a');
console.log(a);
a.href = uri + base64(format(template, ctx))
a.download = 'Excel Report.xls';
//triggering the function
a.click();
}
})();
</script>

</div></div>

 

 

Server Script-->

 

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.src="resource_reports.do?sysparm_filters_enabled=true&sysparm_report_type=availability";

})();

 

 

Link Function-->

 

function link(scope, element, attrs, controller) {
var panel_height;

 

$(document).ready(function(){
resize_window();
});

 

$(window).resize(function(){
resize_window();
});

 

function resize_window(){
var panel_height = ($(document).height()- 64) + 'px';
$(elem).find('#root_cause_analysis').css('height',panel_height);
}
}

0 REPLIES 0