首先datagrid加载的表格代码部分为(HTML):
<table id="testResultId" style="display: none"></table>
导出文件代码部分(HTML):
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true" onclick="ExporterExcel()">导出</a>
然后是<script>函数:
//表格导出开始,将json对象导出为CSV文件
function JSONToCSVConvertor(JSONData, ReportTitle, ShowLabel) {
//If JSONData is not an object then JSON.parse will parse the JSON string in an Object
var arrData = typeof JSONData != 'object' ? JSON.parse(JSONData)
: JSONData;
var CSV = '';
//Set Report title in first row or line
CSV += ReportTitle + '\r\n\n';
//This con