angular .module("solJIRAApp") .factory('ExcelExportFactory', ExcelExportFactory); function ExportExcelFactory($window) { var self = this; var uri = 'data:application/vnd.ms-excel;base64,'; var template = '{table}
'; return { tableToExcel: tableToExcel }; function base64(s) { return $window.btoa(unescape(encodeURIComponent(s))); } function format(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }); } function tableToExcel(tableId, worksheetName) { var table = $(tableId); var ctx = { worksheet: worksheetName, table: table.html() }; var href = uri + base64(format(template, ctx)); return href; } }