求救!将JSP页面的数据导入到WORD中!!! 好象是将jsp页的头设置成word格式的就可以了,具体语法我忘记了,你查查网上资料吧,反正是一定可以的~~ 设置成excel也可以! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ page contentType="application/msword; charset=gb2312" language="java"%>可以将页面内容转化为WORD,但如果打印中如果有图片和表格,我也没有办法处理。 将Word文件导到JSP页面<object id=FileDialog style="left: 0px; TOP: 0px" classid="clsid:f9043c85-f6f2-101a-a3c9-08002b2f49fb" codebase="http://activex.microsoft.com/controls/vb5/comdlg32.cab"></object><input type=button value="打开Word文档" onclick='OpenFile()'><input type=button value="HTML格式" onclick='window.confirm(App.innerHTML)'><div align=left id=App style="border:1 solid #000000;background-color:#FFFFFF;height:400px;overflow:auto;width:100%;z-index:2" contentEditable></div><script>function OpenFile(){ try { FileDialog.CancelError=true; FileDialog.Filter="Word模板|*.doc|Word模板|*.dot"; FileDialog.ShowOpen(); var WordApp=new ActiveXObject("Word.Application"); WordApp.Application.Visible=false; var Doc=WordApp.Documents.Open(FileDialog.filename); Doc.Activate(); Doc.Parent.Options.InsertedTextColor=4; Doc.Parent.Options.InsertedTextMark=2; Doc.Parent.Options.DeletedTextColor=4; Doc.Parent.Options.DeletedTextMark=1; Doc.TrackRevisions=true; Doc.PrintRevisions=true; Doc.ShowRevisions=true; Doc.Application.UserName=""; var Range=Doc.Range(); Range.Select(); var Selection=WordApp.Selection; Selection.Copy(); App.focus(); document.execCommand("Paste"); App.focus(); WordApp.DisplayAlerts=false; Doc.Close(); WordApp.DisplayAlerts=true; WordApp.Quit(); } catch(e){} return false;}</script> 打印function PrintFile(){ var strResult=window.confirm("确认用Word打印吗?"); if(strResult) { try { App.focus(); document.execCommand("SelectAll"); document.execCommand("Copy"); App.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;} 这个太难了。有人说用activeX可以,不可始终没有亲见。我写过几次。每次都试着用不同的方法,不过很遗憾,每次都是除了.doc不行外,其它的都行。如果要转换成其它格式,我可以帮你,就这个.doc我帮不上忙 如何取得数据库中所有行的数据显示在jsp页面中? 向前辈们请教两个问题 cannot be resolved to a type 推荐个JAVA开源的CMS系统 JSP如何检查不同服务器上的SESSION Tomcat5.5经常出现这样的警告信息。很郁闷 请教:Servlet及Jsp如何配置运行?谢谢! 怎么取到sqlserver的系统存储过程sp_cursorfetch返回的结果集? 关于流量统计代码,请找错误,百思不得其解 jsp配置驱动怎么弄啊!!! 在线等,解决即给分~! 求助:问题很简单。
<object id=FileDialog style="left: 0px; TOP: 0px" classid="clsid:f9043c85-f6f2-101a-a3c9-08002b2f49fb" codebase="http://activex.microsoft.com/controls/vb5/comdlg32.cab">
</object>
<input type=button value="打开Word文档" onclick='OpenFile()'>
<input type=button value="HTML格式" onclick='window.confirm(App.innerHTML)'>
<div align=left id=App style="border:1 solid #000000;background-color:#FFFFFF;height:400px;overflow:auto;width:100%;z-index:2" contentEditable></div>
<script>
function OpenFile()
{
try
{
FileDialog.CancelError=true;
FileDialog.Filter="Word模板|*.doc|Word模板|*.dot";
FileDialog.ShowOpen();
var WordApp=new ActiveXObject("Word.Application");
WordApp.Application.Visible=false;
var Doc=WordApp.Documents.Open(FileDialog.filename);
Doc.Activate();
Doc.Parent.Options.InsertedTextColor=4;
Doc.Parent.Options.InsertedTextMark=2;
Doc.Parent.Options.DeletedTextColor=4;
Doc.Parent.Options.DeletedTextMark=1;
Doc.TrackRevisions=true;
Doc.PrintRevisions=true;
Doc.ShowRevisions=true;
Doc.Application.UserName="";
var Range=Doc.Range();
Range.Select();
var Selection=WordApp.Selection;
Selection.Copy();
App.focus();
document.execCommand("Paste");
App.focus();
WordApp.DisplayAlerts=false;
Doc.Close();
WordApp.DisplayAlerts=true;
WordApp.Quit();
}
catch(e){}
return false;
}
</script>
function PrintFile()
{
var strResult=window.confirm("确认用Word打印吗?");
if(strResult)
{
try
{
App.focus();
document.execCommand("SelectAll");
document.execCommand("Copy");
App.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;
}