PageMargins margins; // Get the PageMargins structure and set the
// margins for the report.
ReportDocument Report = new ReportDocument();
string path = Server.MapPath("企业登记基本情况_分年统计周.rpt");
Report.Load(path);
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)";
Report.PrintOptions.PrinterName = printerName; // Print the report. Set the startPageN and endPageN
// parameters to 0 to print all pages.
Report.SetDataSource(ds);
Report.PrintToPrinter(1, false,0,1);
// margins for the report.
ReportDocument Report = new ReportDocument();
string path = Server.MapPath("企业登记基本情况_分年统计周.rpt");
Report.Load(path);
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)";
Report.PrintOptions.PrinterName = printerName; // Print the report. Set the startPageN and endPageN
// parameters to 0 to print all pages.
Report.SetDataSource(ds);
Report.PrintToPrinter(1, false,0,1);
解决方案 »
- asp.net mvc spring.net nhibernate错误'hibernate' node cannot be resolved for the s
- 请问这是什么语法?
- 操作硬盘文件,是还是必须写activex
- .aspx模板不能当模板生成静态页吗?
- 就辈子最可怜就是书读的太少,请教英文
- 帮忙做个ASP导入导出EXCEL的完全型代码或直接给模块SQL数据库
- 问个问题!谢谢!
- 一个基于AJAX的邮政编码查询系统,请大家提提建议。
- 50分 !!急!! 问一个DataList控件中的imageButton的问题!
- 运行时界面代码出现错误!!大家给点意见
- 在现实中碰到的问题!关于如何保存用户的信息。问题较难!欢迎大家讨论
- !!!为什么c#没有四舍五入的能力!!!
Dim oRpt As New crpt3()
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
BindReport("Select * from Mytree")
End Sub
Sub BindReport(ByVal SQL As String) Dim myConnection As New SqlClient.SqlConnection() myConnection.ConnectionString = "Persist Security Info=False;User ID=sa;pwd=;Initial Catalog=drkhorse;Data Source=CRM\CRM" Dim MyCommand As New SqlClient.SqlCommand() MyCommand.Connection = myConnection MyCommand.CommandText = SQL MyCommand.CommandType = CommandType.Text Dim MyDA As New SqlClient.SqlDataAdapter() MyDA.SelectCommand = MyCommand
'已建好的DATASET的文件
Dim myDS As New Dataset2()
'This is our DataSet created at Design Time
MyDA.Fill(myDS, "Mytree")
'You have to use the same name as that of your Dataset that you created during design time
' Dim oRpt As New crpt3()
' This is the Crystal Report file created at Design Time
oRpt.SetDataSource(myDS)
' Set the SetDataSource property of the Report to the Dataset
CrystalReportViewer1.ReportSource = oRpt ' Set the Crystal Report Viewer's property to the oRpt Report object that we created
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
BindReport("select * from Mytree where name like '9%'")
End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
BindReport("select * from Mytree")
End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
' oRpt.PrintOptions.PrinterName = "Canon S400在GW-SERVER上"
oRpt.PrintOptions.PrinterName = "\\\\GW-SERVER\\Canon S400"
' oRpt.PrintOptions.PrinterName = "Canon S400"
oRpt.PrintToPrinter(1, True, 1, 2)
End Sub
可还是不行啊.提示错误.
文件 C:\WIN2000\TEMP\temp_a977e0de-c830-4691-824c-ba502935dbd0.rpt 内出错:指定的打印机无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: CrystalDecisions.CrystalReports.Engine.InvalidArgumentException: 文件 C:\WIN2000\TEMP\temp_a977e0de-c830-4691-824c-ba502935dbd0.rpt 内出错:指定的打印机无效。源错误:
行 71: Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
行 72: ' oRpt.PrintOptions.PrinterName = "Canon S400在GW-SERVER上"
行 73: oRpt.PrintOptions.PrinterName = "\\\\GW-SERVER\\Canon S400"
行 74: ' oRpt.PrintOptions.PrinterName = "Canon S400"
行 75: oRpt.PrintToPrinter(1, True, 1, 2)
打印机明明有啊.