{"action":"created","issue":{"url":"https://api.github.com/repos/rainabba/jquery-table2excel/issues/48","repository_url":"https://api.github.com/repos/rainabba/jquery-table2excel","labels_url":"https://api.github.com/repos/rainabba/jquery-table2excel/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/rainabba/jquery-table2excel/issues/48/comments","events_url":"https://api.github.com/repos/rainabba/jquery-table2excel/issues/48/events","html_url":"https://github.com/rainabba/jquery-table2excel/issues/48","id":168017890,"number":48,"title":"How to set the name of the export file","user":{"login":"grey5659","id":9668962,"avatar_url":"https://avatars.githubusercontent.com/u/9668962?v=3","gravatar_id":"","url":"https://api.github.com/users/grey5659","html_url":"https://github.com/grey5659","followers_url":"https://api.github.com/users/grey5659/followers","following_url":"https://api.github.com/users/grey5659/following{/other_user}","gists_url":"https://api.github.com/users/grey5659/gists{/gist_id}","starred_url":"https://api.github.com/users/grey5659/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grey5659/subscriptions","organizations_url":"https://api.github.com/users/grey5659/orgs","repos_url":"https://api.github.com/users/grey5659/repos","events_url":"https://api.github.com/users/grey5659/events{/privacy}","received_events_url":"https://api.github.com/users/grey5659/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-28T05:50:29Z","updated_at":"2016-07-28T06:22:58Z","closed_at":null,"body":""},"comment":{"url":"https://api.github.com/repos/rainabba/jquery-table2excel/issues/comments/235809518","html_url":"https://github.com/rainabba/jquery-table2excel/issues/48#issuecomment-235809518","issue_url":"https://api.github.com/repos/rainabba/jquery-table2excel/issues/48","id":235809518,"user":{"login":"binalpanchal","id":13871608,"avatar_url":"https://avatars.githubusercontent.com/u/13871608?v=3","gravatar_id":"","url":"https://api.github.com/users/binalpanchal","html_url":"https://github.com/binalpanchal","followers_url":"https://api.github.com/users/binalpanchal/followers","following_url":"https://api.github.com/users/binalpanchal/following{/other_user}","gists_url":"https://api.github.com/users/binalpanchal/gists{/gist_id}","starred_url":"https://api.github.com/users/binalpanchal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/binalpanchal/subscriptions","organizations_url":"https://api.github.com/users/binalpanchal/orgs","repos_url":"https://api.github.com/users/binalpanchal/repos","events_url":"https://api.github.com/users/binalpanchal/events{/privacy}","received_events_url":"https://api.github.com/users/binalpanchal/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T06:22:58Z","updated_at":"2016-07-28T06:22:58Z","body":" $('#tblExport').table2excel({\r\n                         exclude: \".noExl\",\r\n                         name: \"report\",\r\n                         filename: \"Report\",     // Here, you can assign exported file name\r\n                         fileext: \".xls\"\r\n                      })\r\n------------------------------------------------\r\nAnd try this below jquery-table2excel:\r\n//table2excel.js\r\n;(function ( $, window, document, undefined ) {\r\n    var pluginName = \"table2excel\",\r\n\r\n    defaults = {\r\n        exclude: \".noExl\",\r\n                name: \"Table2Excel\"\r\n    };\r\n\r\n    // The actual plugin constructor\r\n    function Plugin ( element, options ) {\r\n            this.element = element;\r\n            // jQuery has an extend method which merges the contents of two or\r\n            // more objects, storing the result in the first object. The first object\r\n            // is generally empty as we don't want to alter the default options for\r\n            // future instances of the plugin\r\n            //\r\n            this.settings = $.extend( {}, defaults, options );\r\n            this._defaults = defaults;\r\n            this._name = pluginName;\r\n            this.init();\r\n    }\r\n\r\n    Plugin.prototype = {\r\n        init: function () {\r\n            var e = this;\r\n\r\n\t\t\tvar utf8Heading = \"<meta http-equiv=\\\"content-type\\\" content=\\\"application/vnd.ms-excel; charset=UTF-8\\\">\";\r\n            e.template = {\r\n\t\t\t\thead: \"<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\\\">\" + utf8Heading + \"<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets>\",\r\n                sheet: {\r\n                    head: \"<x:ExcelWorksheet><x:Name>\",\r\n                    tail: \"</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>\"\r\n                },\r\n                mid: \"</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>\",\r\n                table: {\r\n                    head: \"<table>\",\r\n                    tail: \"</table>\"\r\n                },\r\n                foot: \"</body></html>\"\r\n            };\r\n\r\n            e.tableRows = [];\r\n\r\n            // get contents of table except for exclude\r\n            $(e.element).each( function(i,o) {\r\n                var tempRows = \"\";\r\n                $(o).find(\"tr\").not(e.settings.exclude).each(function (i,o) {\r\n                    tempRows += \"<tr>\" + $(o).html() + \"</tr>\";\r\n                });\r\n                e.tableRows.push(tempRows);\r\n            });\r\n\r\n            e.tableToExcel(e.tableRows, e.settings.name, e.settings.sheetName);\r\n        },\r\n\r\n        tableToExcel: function (table, name, sheetName) {\r\n            var e = this, fullTemplate=\"\", i, link, a;\r\n\r\n            e.uri = \"data:application/vnd.ms-excel;base64,\";\r\n            e.base64 = function (s) {\r\n                return window.btoa(unescape(encodeURIComponent(s)));\r\n            };\r\n            e.format = function (s, c) {\r\n                return s.replace(/{(\\w+)}/g, function (m, p) {\r\n                    return c[p];\r\n                });\r\n            };\r\n\r\n            sheetName = typeof sheetName === \"undefined\" ? \"Sheet\" : sheetName;\r\n\r\n            e.ctx = {\r\n                worksheet: name || \"Worksheet\",\r\n                table: table,\r\n                sheetName: sheetName,\r\n            };\r\n\r\n            fullTemplate= e.template.head;\r\n\r\n            if ( $.isArray(table) ) {\r\n                for (i in table) {\r\n                      //fullTemplate += e.template.sheet.head + \"{worksheet\" + i + \"}\" + e.template.sheet.tail;\r\n                      fullTemplate += e.template.sheet.head + sheetName + i + e.template.sheet.tail;\r\n                }\r\n            }\r\n\r\n            fullTemplate += e.template.mid;\r\n\r\n            if ( $.isArray(table) ) {\r\n                for (i in table) {\r\n                    fullTemplate += e.template.table.head + \"{table\" + i + \"}\" + e.template.table.tail;\r\n                }\r\n            }\r\n\r\n            fullTemplate += e.template.foot;\r\n\r\n            for (i in table) {\r\n                e.ctx[\"table\" + i] = table[i];\r\n                fullTemplate = e.format(fullTemplate, e.ctx);\r\n            }\r\n            delete e.ctx.table;\r\n\r\n            if (typeof msie !== \"undefined\" && msie > 0 || !!navigator.userAgent.match(/Trident.*rv\\:11\\./))      // If Internet Explorer\r\n            {\r\n                if (typeof Blob !== \"undefined\") {\r\n                    //use blobs if we can\r\n                    fullTemplate = [fullTemplate];\r\n                    //convert to array\r\n                    var blob1 = new Blob(fullTemplate, { type: \"text/html\" });\r\n                    window.navigator.msSaveBlob(blob1, getFileName(e.settings) );\r\n                } else {\r\n                    //otherwise use the iframe and save\r\n                    //requires a blank iframe on page called txtArea1\r\n                    txtArea1.document.open(\"text/html\", \"replace\");\r\n                    txtArea1.document.write(e.format(fullTemplate, e.ctx));\r\n                    txtArea1.document.close();\r\n                    txtArea1.focus();\r\n                    sa = txtArea1.document.execCommand(\"SaveAs\", true, getFileName(e.settings) );\r\n                }\r\n\r\n            } else {\r\n                link = e.uri + e.base64(e.format(fullTemplate, e.ctx));\r\n                a = document.createElement(\"a\");\r\n                a.download = getFileName(e.settings);\r\n                a.href = link;\r\n\r\n                document.body.appendChild(a);\r\n\r\n                a.click();\r\n\r\n                document.body.removeChild(a);\r\n            }\r\n\r\n            return true;\r\n        }\r\n    };\r\n\r\n    function getFileName(settings) {\r\n\t\treturn ( settings.filename ? settings.filename : \"table2excel\" ) +\r\n\t\t\t   ( settings.fileext ? settings.fileext : \".xlsx\" );\r\n    }\r\n\r\n    $.fn[ pluginName ] = function ( options ) {\r\n        var e = this;\r\n            e.each(function() {\r\n                if ( !$.data( e, \"plugin_\" + pluginName ) ) {\r\n                    $.data( e, \"plugin_\" + pluginName, new Plugin( this, options ) );\r\n                }\r\n            });\r\n\r\n        // chain jQuery functions\r\n        return e;\r\n    };\r\n\r\n})( jQuery, window, document );\r\n\r\n"}}
{"actor":{"display_login":"binalpanchal"}}