JS 在页面上直接将json数据导出到excel,支持chrome,edge,IE10+,IE9,IE8,Safari,Firefox
<html>
<head>
</head>
<body>
<script type="text/javascript">
function jsexport(){
var jsonData = [{name:"张三", sex:"男", age:46},{name:"李四", sex:"男", age:20},{name:"王五", sex:"男", age:33},{name:"赵六", sex:"男", age:80}];
var GridData = JSON.parse(JSON.stringify(jsonData))
JSONToCSV(GridData, "UserReport.csv", true);
}
var blob;
var filename;
function c(){
window.navigator.msSaveOrOpenBlob(blob, filename);
}
function JSONToCSV(JSONData, ReportName, ShowLabel) {
var arrData = typeof JSONData != 'object' ? JSON.parse(JSONData