最近一個項目使用ReportViewer來呈現本地RDLC模塊的報表,需要用戶點擊至少三次才能直正打印, 用戶感覺易用性很不好,需要我們修改。
經過網上查找相關資料,發現直接使用ACTIVEX控件RSClientPrint直接打印使用SQLSERVER報表服務的 資料很多,也說的比較詳細,可唯獨沒打印本地報表的相關內容,看來只能自已摸索了。
經過研究有關打印SQLSERVER報表服務的資料,特別是這篇文章: http://www.codeproject.com/KB/reporting-services/RsClientPrint.aspx,決下先寫一個簡單的HTML 文 件測試一下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<BODY onload="Print()">
<OBJECT ID="RSClientPrint"
classid="CLSID:5554DCB0-700B-498D-9B58-4E40E5814405" CODEBASE="/RSClientPrint-x86.cab" VIEWASTEXT></OBJECT>
<script type="text/javascript" language="javascript">
function Print(oid,name) {
if (typeof RSClientPrint.Print == "undefined") {
alert("Unable to load client print control.");
return;
}
RSClientPrint.MarginLeft = 0;
RSClientPrint.MarginTop = 0;
RSClientPrint.MarginRight = 0;
RSClientPrint.MarginBottom = 0;
RSClientPrint.PageHeight = 296.926;
RSClientPrint.PageWidth = 210.058;
RSClientPrint.Culture = 2052;
RSClientPrint.UICulture = 2052;
RSClientPrint.UseSingleRequest = true;
RSClientPrint.UseEmfPlus = true;
RSClientPrint.Print ("http://localhost:2940/JDCJY/ReportHandler.ashx", "oid="+escape(oid)+"&name="+escape (name), "test");
}
</script>
</BODY>
</html>