先要把数据按照在excel里显示的样子放在一个字符串里
比如excel里的单元格就要在字符串里用"\t"分隔
换行是"\n"
然后把这个字符串输出到浏览器里header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls"); test.xsl是excel文件的名字
比如excel里的单元格就要在字符串里用"\t"分隔
换行是"\n"
然后把这个字符串输出到浏览器里header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls"); test.xsl是excel文件的名字
var data = obj.outerHTML;
var select = /(\<select)\s*(.*)\>(.*)\<\/select\>/gi;
data = data.replace(select,"");
var a=/(<a)\s*(.+?)>(.+?)<\/a>/gi
var w = window.open("about:blank",null,"height=100,width=100,titlebar=no, status=no,toolbar=no,menubar=no,location=no");
w.document.write(data.replace(a,"$3"));
w.document.execCommand("SaveAs",0,filename);
w.close();
}
导出文件格式无限制,xls为excel