您的位置:首页 > 编程语言 > ASP

asp.net不用CrystalReportViewer 直接打印

2006-11-29 20:11 337 查看
给页面放一个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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐