水晶报表不会玩,
但只要报表在浏览器上显示了,用script调个Print()不就搞定了
但只要报表在浏览器上显示了,用script调个Print()不就搞定了
解决方案 »
- repeater的数据绑定判断问题
- 求你们了!
- 引用母板页的页面怎么提交表单到其它页面
- ASP.NET中DataBinder中的引号问题,请人指导!
- 想请教一下怎么在Microsoft visual studio2005中添加swf文件?
- 急急!!!数据库中的时间为2005-1-1为什么绑定到datagrid变成怎么解决这个问题?!!!!!!!
- 如何用浏览器调用客户端本地的应用程序?
- datalist嵌套datalist后嵌套的数据没有出来..100分
- 有用来ASP.NET 2.0 AJAX的帮忙看看这个问题
- 还是关于弹出窗口的问题!!!
- 关于DropDownList的问题?谢了
- 比股票跌了还急!!!!!!!!!!大家近来看看,帮帮忙!!!!
不能在代码中加入打印机的名称和设置,因为(除非是局域网共享打印机),否则程序无法从服务器端调用客户端的打印机的.
<OBJECT classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2' id='WebBrowser'></OBJECT><input id="Button2" type="button" value="直接打印" onclick="document.all.WebBrowser.ExecWB(6,6)"/> .....——————————————————————
另外,也可以调用javascript打印,参见:
http://aspalliance.com/509
原理是,
1,获取用户数据
2,根据客户筛选的数据构建客户端打印模版,
3,存储模版
4,打印时根据模版重新定位网格填充数据。
5,使用webbrowser打印。其中构建模版用层div,打印时用表格table.如何定位和位置再现是难点。程序仅使用javasceipt 和c#即可。
思路如此,具体代码不便透露。
1、在客户端用window.open打开一个页面用作服务器端处理,在服务端生成图片(应该根据分页计算生成n张图片),使用bitmap.Save方法通过response发送回调用页面
2、在调用页面中的客户端中根据分页的页数动态生成n个<img>(innerHtml),并分别将服务端生成的response的图片流加载到img.src上
3、通过调用window.print()进行打印
如果想去除页头页尾可以使用Activex组件修改客户端的注册表完成
但是这种打印也有缺点,打印图片时的精度不够 (图片打印时字是没有经过打印机处理的,一般都是锯齿字),当然这是可以改进的,比如在服务器端返回一个html流,即一个格式漂亮的html报表,在客户端打印即可,这和我上面描述的道理是一样的这样客户机不用安装什么特别的软件了我现在正在做设置\得到客户端打印机的配置,比如上下左右边距,纸张大小等,还没有什么好的思路,如果哪位有好的提议请告诉我一声,谢谢
http://www.wave12.com/web/home.asp
<input type=button value=打印预览 onclick="wb.execwb(7,1)" style="left: 0px; position: relative; top: -2px"><input type=button onClick=document.all.wb.ExecWB(6,1) value="打印" style="left: 7px; position: relative; top: -2px">
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
function nowPrint(printPage)
{
window.open(printPage+"?temp="+Math.random(),'PrintWin',"height=540,width=800,left=1,top=0,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,menubar=yes,location=yes");
} function printInit()
{
//return;
//PageSetup_Null();
var OLECMDID_PRINT = 7;
var OLECMDEXECOPT_DONTPROMPTUSER = 2;
var OLECMDEXECOPT_PROMPTUSER = 1;
var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
document.body.focus();
document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
//WebBrowser1.ExecWB(7, 2);
WebBrowser1.outerHTML = "";
//window.close();
} function printPage()
{
var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
document.body.focus();
document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
WebBrowser1.ExecWB(6, 1);
}
function factoryPrintPreview(obj,portrait)
{
obj.style.cursor = "wait";
obj.style.visibility = "hidden";
try
{
var factory = "<OBJECT ID=\"factory1\" style=\"DISPLAY: none\" codeBase=\"../ActiveX/smsx.cab\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:1663ED61-23EB-11D2-B92F-008048FDD814\"></OBJECT> ";
//http://www.meadroid.com/scriptx/smsx.cab
document.body.focus();
document.body.insertAdjacentHTML("beforeEnd", factory);
factory1.printing.portrait = portrait;
factory1.printing.header = ""
factory1.printing.footer = "&b第&p页/共&P页&b"
factory1.printing.Preview();
}
catch(e)
{
alert(e.message);
}
obj.style.visibility = "visible";
obj.style.cursor = "default";
} function factoryPrintPage(obj,portrait)
{
prompt("asdasdsada","asdas");
return;
obj.style.cursor = "wait";
obj.style.visibility = "hidden";
try
{
//var factory = "<OBJECT ID=\"factory1\" style=\"DISPLAY: none\" codeBase=\"../ActiveX/smsx.cab\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:1663ED61-23EB-11D2-B92F-008048FDD814\"></OBJECT> "; //document.body.focus();
//document.body.insertAdjacentHTML("beforeEnd", factory);
factory1.printing.portrait = portrait;
factory1.printing.header = ""
factory1.printing.footer = "&b第&p页/共&P页&b"
factory1.printing.Print(false);
//alert("");
InitMsgBox("打印成功!");
}
catch(e)
{
alert(e.message);
}
obj.style.visibility = "visible";
obj.style.cursor = "default";
}