直接打印报告,无需打印对话框和报告查看器

时间:2014-03-31 15:48:48

标签: vb.net printing reporting-services

我需要将报告直接打印到打印机:

1)没有显示打印对话框

2)没有显示Reportviewer

我被建议使用以下代码:

Dim printerSettings As New PrinterSettings()
    Dim printDialog As New PrintDialog()
    printDialog.PrinterSettings = printerSettings
    printDialog.AllowPrintToFile = False
    printDialog.AllowSomePages = True
    printDialog.UseEXDialog = True
    Dim result As DialogResult = printDialog.ShowDialog()

    If result = DialogResult.Cancel Then
        Return
    End If

    Me.rptSalesReport.PrintOptions.PrinterName = printerSettings.PrinterName
    Me.rptSalesReport.PrintToPrinter(printerSettings.Copies, False, 0, 0)

但我在最后两行收到错误,我把报告的名称, rptSalesReport。它说:

rptSalesReport is not defined.

虽然rptSalesReport存在于我的项目中,但我可以通过报表查看器查看它。 请指教。 感谢

0 个答案:

没有答案