Crystal Report的打印问题

anneliang 2003-10-10 12:52:48
Crystal Report的打印的时候,如何直接打印而不打开打印设置窗口?
...全文
46 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
haibodotnet 2003-10-10
  • 打赏
  • 举报
回复
大家一起去这个贴子支持一下!!!
http://expert.csdn.net/Expert/TopicView1.asp?id=2291055
CSDN 开个 Crystal Report 版吧!!!&&&我与水晶报表……
haibodotnet 海波.NET
haibodotnet 2003-10-10
  • 打赏
  • 举报
回复
海波.NET
问题:Crystal Report的打印的时候,如何直接打印而不打开打印设置窗口?
——————————————————————————————————————
解决方案:
ReportDocument.PrintToPrinter 方法
ReportDocument 类 | ReportDocument 成员 | CrystalDecisions.CrystalReports.Engine 命名空间
要求
命名空间:CrystalDecisions.CrystalReports.Engine
平台:Windows 98,Windows NT 4.0,Windows Millennium Edition,Windows 2000
程序集:CrystalDecisions.CrystalReports.Engine

使用 PrintOptions.PrinterName 属性将报表的指定页输出到选定的打印机上。如果未选择打印机,则将使用报表中指定的默认打印机。

[Visual Basic]
Public Overridable Sub PrintToPrinter(ByVal nCopies As Integer, ByVal collated As Boolean, ByVal startPageN As Integer, ByVal endPageN As Integer)
[C#]
public virtual void PrintToPrinter (int nCopies , bool collated , int startPageN , int endPageN );
[C++]
public virtual void PrintToPrinter (int nCopies , bool collated , int startPageN , int endPageN );
参数
nCopies
指明要打印的份数。
collated
指明是否逐份打印。
startPageN
指明要打印的第一页。
endPageN
指明要打印的最后一页。
备注
若要打印所有页,请将 startPageN 参数和 endPageN 参数设置为零。

示例
下面的示例设置报表的页边距,选择打印机,并打印报表。

[Visual Basic]
Private Sub PrintReport(ByVal printerName As String)
Dim margins As PageMargins

' 获取 PageMargins 结构并设置
' 报表边距。
margins = Report.PrintOptions.PageMargins
margins.bottomMargin = 350
margins.leftMargin = 350
margins.rightMargin = 350
margins.topMargin = 350
' 应用页边距。
Report.PrintOptions.ApplyPageMargins(margins)

' 选择打印机。
Report.PrintOptions.PrinterName = printerName

' 打印报表。将 startPageN 和 endPageN
'参数设置为 0 表示打印所有页。
Report.PrintToPrinter(1, False, 0, 0)
End Sub
[C#]
private void PrintReport(string printerName)
{
PageMargins margins;

// 获取 PageMargins 结构并设置
//报表的边距。
margins = Report.PrintOptions.PageMargins;
margins.bottomMargin = 350;
margins.leftMargin = 350;
margins.rightMargin = 350;
margins.topMargin = 350;
// 应用页边距。
Report.PrintOptions.ApplyPageMargins(margins);

// 选择打印机。
Report.PrintOptions.PrinterName = printerName;

// 打印报表。将 startPageN 和 endPageN
// 参数设置为 0 表示打印所有页。
Report.PrintToPrinter(1, false,0,0);
}
[C++]
void PrintReport(String* printerName)
{
PageMargins margins;

// 获取 PageMargins 结构并设置
//报表的边距。
margins = Report->PrintOptions->PageMargins;
margins.bottomMargin = 350;
margins.leftMargin = 350;
margins.rightMargin = 350;
margins.topMargin = 350;
// 应用页边距。
Report->PrintOptions->ApplyPageMargins(margins);

// 选择打印机。
Report->PrintOptions->PrinterName = printerName;

// 打印报表。将 startPageN 和 endPageN
// 参数设置为 0 表示打印所有页。
Report->PrintToPrinter(1, false,0,0);
};

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧