c# 打印常用报表方案:
1、水晶报表CrystalReport,以CR2008为例,添加引用CrystalDecisions.CrystalReports.Engine.dll、CrystalDecisions.ReportSource.dll、CrystalDecisions.Shared.dll、CrystalDecisions.Windows.Forms.dll。
服务端代码:接收客户端传入的报表名字,参数列表,服务端执行报表,并将结果以字节数组的形式返回。
public bool RunRpt(string RptFullName, Dictionary<string, object> RptParams, TableLogOnInfo logOnInfo, ExportFormatType exportFormatType, string OutPutFileName, string userid) {
Stream stream=null; using (ReportDocument cr = new ReportDocument()) {
try {
cr.Load(AppDomain.CurrentDomain.BaseDirectory + "rpt\\" + RptFullName); cr.SetDatabaseLogon(logOnInfo.ConnectionInfo.UserID, logOnInfo.ConnectionInfo.Password, logOnInfo.ConnectionInfo.ServerName, logOnInfo.ConnectionInfo.DatabaseName); if (RptParams != null) {
foreach (KeyValuePair<string, object> kv in RptParams) {
cr.SetParameterValue(kv.Key, kv.Value); } } ICallback callback = O