Home  >  Article  >  Web Front-end  >  Detailed explanation of five methods to export Excel using JS

Detailed explanation of five methods to export Excel using JS

亚连
亚连Original
2018-05-30 10:04:405786browse

This article mainly introduces the five methods of exporting Excel using JS, and analyzes in detail the relevant operating techniques for exporting Excel files based on tables in the form of examples. The source code is also attached for readers to download and refer to. Friends who need it can refer to it. Next

The examples in this article describe five methods of exporting Excel using JS. Share it with everyone for your reference, the details are as follows:

The first four methods of these five methods only support the IE browser, and the last method supports the current mainstream browsers (Firefox, IE, Chrome, Opera, Safari)





  
  html 表格导出道
  
{table}
', 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(table) var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML} window.location.href = uri + base64(format(template, ctx)) } })()

html 表格导出道Excel
列标题1 列标题2 类标题3 列标题4 列标题5
aaa bbb ccc ddd eee
AAA BBB CCC DDD EEE
FFF GGG HHH III JJJ


I came up today and found that many people will encounter problems with file names, formats, etc. Add a method here. I have not tested the compatibility. You can try it, but you need to use JQ to post the code directly. The source code can be found here下载. Note that you must quote the files corresponding to jquery-3.2.1.min.js and jquery.table2excel.js. jquery-3.2.1.min.js depends on your corresponding file version, it doesn’t matter. If you have any questions, criticism and guidance are welcome.





  
  html 表格导出道
  
  
  

html 表格导出道Excel
列标题1 列标题2 类标题3 列标题4 列标题5
aaa bbb ccc ddd eee
AAA BBB CCC DDD EEE
FFF GGG HHH III JJJ

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Detailed explanation of Vue.js project API and Router configuration split practice

Vue implements active click switching Method

Example of mobile phone number, email regular verification and verification code sent in 60 seconds in vue

The above is the detailed content of Detailed explanation of five methods to export Excel using JS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn