打印
http://www.cnblogs.com/mushanbinzi/archive/2009/11/08/1598352.html
http://www.cnblogs.com/wfnice12/archive/2009/01/02/1367003.html
http://www.cnblogs.com/blsong/archive/2009/12/03/1616365.html
http://www.cnblogs.com/wfnice12/archive/2009/12/04/1616934.html
http://www.cnblogs.com/hanwater/archive/2009/11/04/1595986.html
http://www.cnblogs.com/michaelxu/archive/2009/05/31/1493029.html
http://www.cnblogs.com/sevendays/archive/2009/07/11/1520874.html
http://blog.csdn.net/xuejiayue1105/archive/2009/12/04/4940220.aspx
WEB程序需要打印格式页面时解决方案汇总
view plaincopy to clipboardprint?
<mce:style media=print><!--
.noprint{display:none;}
.PageNext{page-break-after: always;}
--></mce:style><style media=print mce_bogus="1">
.noprint{display:none;}
.PageNext{page-break-after: always;} </style>
<mce:style media=print><!--
.noprint{display:none;}
.PageNext{page-break-after: always;}
--></mce:style><style media=print mce_bogus="1">
.noprint{display:none;}
.PageNext{page-break-after: always;} </style>
view plaincopy to clipboardprint?
//页面里面的代码,非常经典的WEB打印代码
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0>
</OBJECT>
<!-- <input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)> -->
<input name="Submit2" type="button" value="返回重选" onClick="history.back(1);">
<input name="button" type=button onclick=document.all.WebBrowser.ExecWB(8,1) value=页面设置>
<input name="button" type=button onClick=document.all.WebBrowser.ExecWB(7,1) value=打印预览>
<input name="button" type=button onClick=document.all.WebBrowser.ExecWB(6,6) value=打印>
<input name="submit" type=submit value=提交>
//页面里面的代码,非常经典的WEB打印代码
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0>
</OBJECT>
<!-- <input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)> -->
<input name="Submit2" type="button" value="返回重选" onClick="history.back(1);">
<input name="button" type=button onclick=document.all.WebBrowser.ExecWB(8,1) value=页面设置>
<input name="button" type=button onClick=document.all.WebBrowser.ExecWB(7,1) value=打印预览>
<input name="button" type=button onClick=document.all.WebBrowser.ExecWB(6,6) value=打印>
<input name="submit" type=submit value=提交>
网上网友整理的对于这方面的资料
对IEWebBrowser这个组件的execWB方法整理了一下
1. <object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>
2. 调用方法。
WebBrowser.ExecWB nCmdID, nCmdExecOpt, [pvaIn], [pvaOut]
3. 参数说明。
(a).nCmdID
OLECMDID_OPEN = 1,
OLECMDID_NEW = 2,
OLECMDID_SAVE = 3,
OLECMDID_SAVEAS = 4,
OLECMDID_SAVECOPYAS = 5,
OLECMDID_PRINT = 6,
OLECMDID_PRINTPREVIEW = 7,
OLECMDID_PAGESETUP = 8,
OLECMDID_SPELL = 9,
OLECMDID_PROPERTIES = 10,
OLECMDID_CUT = 11,
OLECMDID_COPY = 12,
OLECMDID_PASTE = 13,
OLECMDID_PASTESPECIAL = 14,
OLECMDID_UNDO = 15,
OLECMDID_REDO = 16,
OLECMDID_SELECTALL = 17,
OLECMDID_CLEARSELECTION = 18,
OLECMDID_ZOOM = 19,
OLECMDID_GETZOOMRANGE = 20
OLECMDID_UPDATECOMMANDS = 21
OLECMDID_REFRESH = 22
OLECMDID_STOP = 23
OLECMDID_HIDETOOLBARS = 24
OLECMDID_SETPROGRESSMAX = 25
OLECMDID_SETPROGRESSPOS = 26
OLECMDID_SETPROGRESSTEXT = 27
OLECMDID_SETTITLE = 28
OLECMDID_SETDOWNLOADSTATE = 29
OLECMDID_STOPDOWNLOAD = 30
上面的关键词都可以在浏览器的菜单里面找到对应的选项﹐大家一看就明白的﹗
(b).nCmdExecOpt
OLECMDEXECOPT_DODEFAULT = 0,
OLECMDEXECOPT_PROMPTUSER = 1,
LECMDEXECOPT_DONTPROMPTUSER = 2,
OLECMDEXECOPT_SHOWHELP = 3
对于这个参数﹐一般来说﹐选1就可以了。
这是调用IE的”另存为”功能的示例﹕
<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>
<A href="javascript:WebBrowser.ExecWB(4,1);">Save-存储</A>
______________________________________________________________________________________________
OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=WebBrowser width=0></OBJECT>
<table><tr><td>
<input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打开>
</td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(2,1)
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存为></td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=属性></td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印></td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(6,6) type=button value=打印>不会弹出打印机窗口</td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(7,1) type=button value=打印预览 ></td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=页面设置></td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=查看页面属性></td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(15,1) type=button value=撤销></td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(17,1) type=button value=全选></td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(22,1) type=button value=刷新></td></tr>
<tr><td><input name=Button onClick=document.all.WebBrowser.ExecWB(45,1) type=button value=关闭窗体无提示></td></tr>
<tr><td><input type=button value=刷新 name=refresh onclick="window.location.reload()">
</td></tr>
--------------------------------------------------------------------------------
另外 对于 GRIVIEW显示需要打印换页的 用了下面的解决方案
在GridView1_RowDataBound实践中插入一列放行号,根据行号%10 (就是每10行更换一页),插入一个新行
view plaincopy to clipboardprint?
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex != -1)
{
int id = e.Row.RowIndex + 1;
//实现每10行分页的 但是效果不是很好
if (id%10==0)
{
GridViewRow newRow = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal);
newRow.Cells.Add(new TableCell());
newRow.Cells[0].ColumnSpan = e.Row.Cells.Count;
newRow.Cells[0].Text = "<div class=PageNext></div>";
this.GridView1.Controls[0].Controls.Add(newRow);
}
e.Row.Cells[0].Text = id.ToString();
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex != -1)
{
int id = e.Row.RowIndex + 1;
//实现每10行分页的 但是效果不是很好
if (id%10==0)
{
GridViewRow newRow = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal);
newRow.Cells.Add(new TableCell());
newRow.Cells[0].ColumnSpan = e.Row.Cells.Count;
newRow.Cells[0].Text = "<div class=PageNext></div>";
this.GridView1.Controls[0].Controls.Add(newRow);
}
e.Row.Cells[0].Text = id.ToString();
}
}
另外CSDN的网友 也有更加详细的一篇整理 几乎非常完整 ,但是里面用EXCEL的方法打印 我没有调试出来 ,先记录下来。
http://blog.csdn.net/xwchen/archive/2007/05/31/1633103.aspx
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xuejiayue1105/archive/2009/12/04/4940220.aspx