页面用word的方式下载的方式很多,我值介绍两种方式吧!~!
第一种:这种方式比较简单!~!只需要在jsp页面的<@ page>指令里面添加一个
contentTeyp="application/msword" 就可以了!~!
第二种:用JavaScript脚本控制也可以!~!相关代码如下:
<script type="text/javascript">
function PrintFile()
{
var strResult=window.confirm("确认用Word打印吗?");
if(strResult)
{
try
{
tableId.focus();
document.execCommand("SelectAll");
document.execCommand("Copy");
tableId.focus();
var WordApp=new ActiveXObject("Word.Application");
WordApp.Application.Visible=true;
var Doc=WordApp.Documents.Add();
Doc.Activate();
Doc.Content.Paste();
Doc.PrintPreview();
WordApp.DisplayAlerts=false;
Doc.Close();
WordApp.DisplayAlerts=true;
WordApp.Quit();
}
catch(e){}
}
else
{
var hwnd=window.open("");
hwnd.document.write(App.innerHTML);
}
return false;
}
</script>
然后再调用一下这个函数就可以了