jsp实现打印功能 我想用jsp实现打印功能,且能对页面进行设置,能预览,并且打印的时候不要打印显示打印的按钮 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 此回复为自动发出,仅用于显示而已,并无任何其他特殊作用楼主【shangguanxuekui】截止到2008-08-01 10:40:51的历史汇总数据(不包括此帖):发帖的总数量:2 发帖的总分数:140 每贴平均分数:70 回帖的总数量:5 得分贴总数量:1 回帖的得分率:20% 结贴的总数量:2 结贴的总分数:140 无满意结贴数:0 无满意结贴分:0 未结的帖子数:0 未结的总分数:0 结贴的百分比:100.00% 结分的百分比:100.00% 无满意结贴率:0.00 % 无满意结分率:0.00 % 敬礼!取消马甲机器人,请点这里:http://www.java2000.net/mycsdn/robotStop.jsp?usern=shangguanxuekui <input type="button" value="打印" class="button" onclick="doPrint()"></script>//打印设置(1)var IframeID=document.getElementById("forprint");function doPrint(){ var url="<%=request.getContextPath()%>/project/projecttenderlistaction.do?act=select" //打印页面 +"&year="+document.all("year").value+"&month="+document.all("month").value+"&export=print"; IframeID.src=url; downjsp();}//延时控制,frame加载完数据后向excel模板添加数据(2)function downjsp(){ try{ if(IframeID.readyState=="complete"){//完全装载时才能保存为图片,要不保存空页面 print_excel(); }else{ setTimeout("downjsp()",100); } }catch(e){ alert(e.message); }}var xls;var xlBook;var xlsheet;//将数据写入excel模板并打印(3)function print_excel(){ try{ xls= new ActiveXObject("Excel.Application"); xlBook = xls.Workbooks.Open("http://<%=request.getServerName()%>:<%=request.getServerPort()%><%=request.getContextPath()%>/projectmanage/project/projecttenderreportlist_print.xls"); xlsheet = xlBook.Worksheets(1) }catch(e){ alert("请启用ActiveX控件设置!操作步骤:\n 1、工具→Internet选项→安全选项卡→Internet→自定义级别 \n 2、启用“对没有标记为安全级别的Active控件进行初始化和脚本运行”!"); return; } try{ if (IframeID.readyState=='complete'){ IframeID.style.display=""; IframeID.focus(); IframeID.document.execCommand('selectAll'); IframeID.document.execCommand('copy');//复制frame数据到剪切板 xlsheet.Paste();//将剪切板数据写入excel模板 xls.visible = false; xlsheet.Printout;//打印excel内容 IframeID.style.display="none"; } }catch(e){ alert(e.description); return; }finally{//关闭excel xls.DisplayAlerts = false; //关闭时不提示保存 xls.Quit(); xls = null; window.setInterval("Cleanup();",1); }}//释放内存(4)function Cleanup() { window.clearInterval(1); CollectGarbage(); }document.getElementById('container').style.width='100%';document.getElementById('container').style.height='80%';var o = new WebFXColumnList();WebFXColumnList.prototype.calcSize = function() { document.getElementById('container').style.width='100%';}function WebFXColumnList() { /* private properties */ this._eCont = null; this._eHead = null; this._eBody = null;}</script> 这是用EXCEL打印的,又没有用WORD打印的,可以设置word的页面 呵呵,刚好最近也在做打印的东东,我是用scriptx控件做的,然后用js控制,当然我用的都是免费的功能,如果你想要页面大小设置这些的话似乎得去买license吧 貌似电信封掉了所以端口了....任何端口都用不起.... struts+hibernate分页 请问这样的效果怎样实现? java操控外设 新手求助~麻烦各位给看看这个问题~谢谢了! 脚本验证双密码的一致,求助个.. 湖南长沙工作经验一两年的同行待遇怎么样?炒了日本,打回老家。 com.jspsmart.upload.*的问题! 链接excel、word文件出现乱码,哪位高手能解决? 如何实现文件浏览 给大家贡献点,欢迎学习,java框架到底是实现什么业务逻辑啊 报表自动发送至用户邮箱???请高手给点意见具体怎么去做??
楼主【shangguanxuekui】截止到2008-08-01 10:40:51的历史汇总数据(不包括此帖):
发帖的总数量:2 发帖的总分数:140 每贴平均分数:70
回帖的总数量:5 得分贴总数量:1 回帖的得分率:20%
结贴的总数量:2 结贴的总分数:140
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
取消马甲机器人,请点这里:http://www.java2000.net/mycsdn/robotStop.jsp?usern=shangguanxuekui
</script>
//打印设置(1)
var IframeID=document.getElementById("forprint");
function doPrint(){
var url="<%=request.getContextPath()%>/project/projecttenderlistaction.do?act=select" //打印页面
+"&year="+document.all("year").value+"&month="+document.all("month").value+"&export=print";
IframeID.src=url;
downjsp();
}
//延时控制,frame加载完数据后向excel模板添加数据(2)
function downjsp(){
try{
if(IframeID.readyState=="complete"){//完全装载时才能保存为图片,要不保存空页面
print_excel();
}else{
setTimeout("downjsp()",100);
}
}catch(e){
alert(e.message);
}
}
var xls;
var xlBook;
var xlsheet;
//将数据写入excel模板并打印(3)function print_excel(){
try{
xls= new ActiveXObject("Excel.Application");
xlBook = xls.Workbooks.Open("http://<%=request.getServerName()%>:<%=request.getServerPort()%><%=request.getContextPath()%>/projectmanage/project/projecttenderreportlist_print.xls");
xlsheet = xlBook.Worksheets(1)
}catch(e){
alert("请启用ActiveX控件设置!操作步骤:\n 1、工具→Internet选项→安全选项卡→Internet→自定义级别 \n 2、启用“对没有标记为安全级别的Active控件进行初始化和脚本运行”!");
return;
}
try{
if (IframeID.readyState=='complete'){
IframeID.style.display="";
IframeID.focus();
IframeID.document.execCommand('selectAll');
IframeID.document.execCommand('copy');//复制frame数据到剪切板
xlsheet.Paste();//将剪切板数据写入excel模板
xls.visible = false;
xlsheet.Printout;//打印excel内容
IframeID.style.display="none";
}
}catch(e){
alert(e.description);
return;
}finally{//关闭excel
xls.DisplayAlerts = false; //关闭时不提示保存
xls.Quit();
xls = null;
window.setInterval("Cleanup();",1);
}
}
//释放内存(4)
function Cleanup() {
window.clearInterval(1);
CollectGarbage();
}
document.getElementById('container').style.width='100%';
document.getElementById('container').style.height='80%';
var o = new WebFXColumnList();
WebFXColumnList.prototype.calcSize = function() {
document.getElementById('container').style.width='100%';
}
function WebFXColumnList() {
/* private properties */
this._eCont = null;
this._eHead = null;
this._eBody = null;
}
</script>