我在VS2008中使用自带的水晶报表建立了一个报表,代码调试的过程中可以直接打印,发布以后可以预览,但是无法直接打印。在IE8.0或者360浏览器中点击打印后就处于长等状态,没有反应。请问有知道解决方法的吗?是不是调用方法不正确?或者是其它权限设置的原因?我把代码粘贴如下:protected void Page_Load(object sender, EventArgs e)
{
CrystalReportViewer1.InitProperties(); if (!IsPostBack)
{
KHA.ULL.ULLAccess ull = new KHA.ULL.ULLAccess();
KHA.ULL.PowerFee fee = ull.CreatePowerFee(); string strUserid = Request.QueryString["userid"].ToString();
string strYearmonth = Request.QueryString["yearmonth"].ToString();
DataTable dt = new DataTable();
decimal dcMoney = 0M;
string strPrice = ""; dt = fee.GetListByUserId(strUserid, DateTime.Parse(strYearmonth),DateTime.Parse(strYearmonth)); dt.Columns.Add("Unitname",typeof(System.String));
dt.Columns.Add("Price",typeof(System.String)); for (int i = 0; i < dt.Rows.Count; i++)
{
if (decimal.Parse(dt.Rows[i]["zdl"].ToString()) == 0)
strPrice = "0";
else
strPrice = (Math.Round(decimal.Parse(dt.Rows[i]["df"].ToString())/decimal.Parse(dt.Rows[i]["zdl"].ToString()),4)).ToString(); dt.Rows[i]["Unitname"] = "费用";
dt.Rows[i]["Price"] = strPrice; dcMoney += decimal.Parse(dt.Rows[i]["df"].ToString());
} string reportPath1 = Server.MapPath("../CrystalReport/CrystalReport1.rpt");
CrystalReportSource1.ReportDocument.Load(reportPath1); CrystalReportSource1.ReportDocument.SetDataSource(dt);
CrystalReportSource1.DataBind(); CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind(); string reportPath2 = Server.MapPath("../CrystalReport/CrystalReport2.rpt");
CrystalReportSource2.ReportDocument.Load(reportPath2); CrystalReportSource2.ReportDocument.SetDataSource(dt);
CrystalReportSource2.DataBind();
}
}//这就是打印按钮事件,注意调用的方法
protected void Button1_Click(object sender, EventArgs e)
{
//CrystalReportSource2.ReportDocument.PrintOptions.PrinterName = @"SmartPrinter";
CrystalReportSource2.ReportDocument.PrintToPrinter(1, false, 0, 0);
}
{
CrystalReportViewer1.InitProperties(); if (!IsPostBack)
{
KHA.ULL.ULLAccess ull = new KHA.ULL.ULLAccess();
KHA.ULL.PowerFee fee = ull.CreatePowerFee(); string strUserid = Request.QueryString["userid"].ToString();
string strYearmonth = Request.QueryString["yearmonth"].ToString();
DataTable dt = new DataTable();
decimal dcMoney = 0M;
string strPrice = ""; dt = fee.GetListByUserId(strUserid, DateTime.Parse(strYearmonth),DateTime.Parse(strYearmonth)); dt.Columns.Add("Unitname",typeof(System.String));
dt.Columns.Add("Price",typeof(System.String)); for (int i = 0; i < dt.Rows.Count; i++)
{
if (decimal.Parse(dt.Rows[i]["zdl"].ToString()) == 0)
strPrice = "0";
else
strPrice = (Math.Round(decimal.Parse(dt.Rows[i]["df"].ToString())/decimal.Parse(dt.Rows[i]["zdl"].ToString()),4)).ToString(); dt.Rows[i]["Unitname"] = "费用";
dt.Rows[i]["Price"] = strPrice; dcMoney += decimal.Parse(dt.Rows[i]["df"].ToString());
} string reportPath1 = Server.MapPath("../CrystalReport/CrystalReport1.rpt");
CrystalReportSource1.ReportDocument.Load(reportPath1); CrystalReportSource1.ReportDocument.SetDataSource(dt);
CrystalReportSource1.DataBind(); CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind(); string reportPath2 = Server.MapPath("../CrystalReport/CrystalReport2.rpt");
CrystalReportSource2.ReportDocument.Load(reportPath2); CrystalReportSource2.ReportDocument.SetDataSource(dt);
CrystalReportSource2.DataBind();
}
}//这就是打印按钮事件,注意调用的方法
protected void Button1_Click(object sender, EventArgs e)
{
//CrystalReportSource2.ReportDocument.PrintOptions.PrinterName = @"SmartPrinter";
CrystalReportSource2.ReportDocument.PrintToPrinter(1, false, 0, 0);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货