Hello everyone,
I've been working on a custom button within the search tab for parts in Aras Innovator. The goal is to export a list of specific parts and their properties through a query and display them in an HTML table.
Here's a snippet of the code I'm using to convert the HTML table to Excel and download the Excel file:
var htmlCode =`
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<script src='https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.16.9/xlsx.full.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js'></script>
<script>
function substituteTableToExcel(){
var table = document.getElementById('all_Parts_AML');
var sheet_name = 'ALL_Parts_AML';
var workbook = XLSX.utils.table_to_book(table, {sheet: sheet_name, cellStyles: true});
var wbout = XLSX.write(workbook, { bookType: 'xlsx', bookSST: true, type: 'array', cellStyles: true });
saveAs(new Blob([wbout], { type: 'application/octet-stream' }), 'ALL_Parts_AML.xlsx');
}
document.addEventListener('DOMContentLoaded', function() {
substituteTableToExcel();
});
</script>
<link rel='stylesheet' type='text/css' href='styles.css'>
</head>
<body>
${excelTable}
</body>
</html>`;
return htmlCode;
I'm encountering issues with the export functionality. When I click the custom button, the HTML table is generated correctly, but the Excel file download doesn't seem to work.
Could someone kindly review the code snippet above and provide any insights or suggestions on how to troubleshoot and resolve this issue? I would greatly appreciate it.
Thank you in advance!
Version 12.0 SP8