jsp中导出excel相当方便,通过简单的js即可。js如下
function excelPrint(objStr,tag_id){
var tempStr = document.getElementById(tag_id).outerHTML;
var newWin = window.open();
newWin.document.write(tempStr);
newWin.document.close();
newWin.document.execCommand('saveas',true,objStr+'.xls');
newWin.window.close();
}
参数说明:
objStr--导出的excel的默认文件名。
tag_id---要导出的html标签的id,可以是table,div等