ITeye博客

jsp导出excel文件

softtian1983 · 2010-01-13 16:36 · JAVA&JSP · Web前端 · Markdown

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等

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。