给页面放一个DropdownList,在PageLoad事件里添加以下代码: For Each iprt As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters DropDownList1.Items.Add(iprt) Next 放一个Button,点击事件为: Dim reportDoc As ReportDocument = New ReportDocument() reportDoc.Load(Server.MapPath("CrystalReport1.rpt")) reportDoc.PrintOptions.PrinterName = DropDownList1.SelectedItem.Text reportDoc.PrintToPrinter(1, False, 0, 0) 在VS2005上测试通过。今天发现一个好的办法,给画面拖一个CrystalReportSource空间CrystalReportSource1,拖一个sqldatasource,在sqldatasource中进行数据筛选,然后将它与CrystalReportSource绑定,执行下边几句进行打印CrystalReportSource1.DataBind(); '取出筛选的数据 CrystalReportSource1.ReportDocument.PrinterName = DropDownList1.SelectedItem.Text CrystalReportSource1.ReportDocument.PrintToPrinter(1, False, 0, 0) 考虑一下水晶报表,很容易实现直接打印 打高度关注PrintToPrinter(1, False, 0, 0)
For Each iprt As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
DropDownList1.Items.Add(iprt)
Next
放一个Button,点击事件为:
Dim reportDoc As ReportDocument = New ReportDocument() reportDoc.Load(Server.MapPath("CrystalReport1.rpt"))
reportDoc.PrintOptions.PrinterName = DropDownList1.SelectedItem.Text
reportDoc.PrintToPrinter(1, False, 0, 0)
在VS2005上测试通过。今天发现一个好的办法,给画面拖一个CrystalReportSource空间CrystalReportSource1,拖一个sqldatasource,在sqldatasource中进行数据筛选,然后将它与CrystalReportSource绑定,执行下边几句进行打印CrystalReportSource1.DataBind(); '取出筛选的数据
CrystalReportSource1.ReportDocument.PrinterName = DropDownList1.SelectedItem.Text
CrystalReportSource1.ReportDocument.PrintToPrinter(1, False, 0, 0)
考虑一下水晶报表,很容易实现直接打印
打高度关注PrintToPrinter(1, False, 0, 0)