首页 > 其他 > 详细

水晶报表打印

时间:2014-11-20 20:26:35      阅读:410      评论:0      收藏:0      [点我收藏+]

水晶报表打印问题:

ReportDocument aReportDocument = new ReportDocument();

//加载报表

 aReportDocument.Load(@Application.StartupPath + Properties.Settings.Default.MainReportPath);

//子报表数据源

aReportDocument.Subreports["SonRpt.rpt"].SetDataSource(sonDs);

//传递参数

 aReportDocument.SetParameterValue("Name", Class.Name);

//登录

foreach (Table aTable in aReportDocument.Database.Tables)
{
 aTable.LogOnInfo.ConnectionInfo.ServerName = Properties.Settings.Default.ServerName;
 aTable.LogOnInfo.ConnectionInfo.UserID = Properties.Settings.Default.UserID;
 aTable.LogOnInfo.ConnectionInfo.Password = Properties.Settings.Default.Password

 aTable.ApplyLogOnInfo(aTable.LogOnInfo);

}

//指定系统默认打印机位报表打印机

 PrintDocument printDc = new PrintDocument();
 aReportDocument.PrintOptions.PrinterName = printDc.PrinterSettings.PrinterName;

//如果没有上面两句,默认打印机是在水晶报表中指定的
 aReportDocument.PrintToPrinter(1, true, 0, 0);
 aReportDocument.Dispose();

水晶报表打印

原文:http://blog.csdn.net/fs1360472174/article/details/41317721

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!