水晶报表打印
打印的基本代码:
CrystalReport1 report = new CrystalReport1(); //Report为你自己的报表名
PageMargins margins;
margins = Report.PrintOptions.PageMargins;
margins.bottomMargin = 250;
margins.leftMargin = 350;
margins.rightMargin = 350;
margins.topMargin = 350;
// Apply the page margins.
Report.PrintOptions.ApplyPageMargins(margins);
// Select the printer.
string printerName = "\\\\局域网机器名\\打印机名(例如HP 2100)"; //本地打印机直接指定名称
Report.PrintOptions.PrinterName = printerName; //指定打印机名称
Report.PrintOptions.PaperSize = PaperSize.PaperA4; //指定纸张尺寸
report.PrintToPrinter(1, true, 1, 4);
下面简单就打印中的参数进行说明:
PrintOptions类,提供用于设置报表打印选项的属性和方法。
PrintOptions成员:
PageContentHeight---Int32,获取页面内容的高度
PageContentWidth---Int32,获取页面内容的宽度
PageMargins---获取报表的边距
PageOrientation---获取或设置打印机纸张方向
Pagesize---获取或设置当前打印机纸张的大小
PrinterName---字符串,获取或设置报表所使用的打印机名称
ReportDocument.PrintToPrinter方法
public virtual void PrintToPrinter( int nCopies, bool collated, int startPageN, int endPageN )
nCopies 指明要打印的分数
collated 指明是否逐份打印
startPageN 指明要打印的第一页
endPageN 指明要打印的最后一页