森林海
var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:"+defaults.type+"' xmlns='http://www.w3.org/TR/REC-html40'>"; excelFile += "<head>"; excelFile += "<!--[if gte mso 9]>"; excelFile += "<xml>"; excelFile += "<x:ExcelWorkbook>"; excelFile += "<x:ExcelWorksheets>"; excelFile += "<x:ExcelWorksheet>"; excelFile += "<x:Name>"; excelFile += "{worksheet}"; excelFile += "</x:Name>"; excelFile += "<x:WorksheetOptions>"; excelFile += "<x:DisplayGridlines/>"; excelFile += "</x:WorksheetOptions>"; excelFile += "</x:ExcelWorksheet>"; excelFile += "</x:ExcelWorksheets>"; excelFile += "</x:ExcelWorkbook>"; excelFile += "</xml>"; excelFile += "<![endif]-->"; excelFile += "</head>"; excelFile += "<body>"; excelFile += excel; excelFile += "</body>"; excelFile += "</html>"; var base64data = "base64," + $.base64.encode(excelFile); window.open('data:application/vnd.ms-'+defaults.type+';filename=exportData.doc;' + base64data);以上代码是jquery.tableExport插件中的部分实现,思路大致就是获取表格里面的内容,将数据以列表形式插入到excel中即可当然我觉得作为一个工程师,最重要一点不要重复造轮子,这对你的成长并没有任何帮助,所谓站在巨人的肩膀上,你才能看的更远、更宽,当然除非你要深入研究开发自己的产品