我的一个页面中有个Crystal Report,还有一些DropDownlist,用于客户端选择报表的参数,然后通过一个button的click事件给一个数据集填充数据,这个数据集是Crystal Report的数据源,现在水晶报表能正常根据通过Dropdownlist选择的参数来显示数据,问题是,水晶报表的导出和打印按钮,无效。点击这两个按钮,页面就刷新一次,没有其他表现,而且水晶报表显示的数据也消失了。请问怎么解决。
另外,怎么自定义水晶报表中导出和打印按钮的click事件
25 个解决方案
#1
这个问题没有碰到,我用的是XtraReports(一个第三方控件的报表),帮顶!
#2
整页代码贴出来 :)
#3
#4
这个要收费吗
#5
//定义载入报表按钮Button_LoadReport的Click事件
protected void Button_LoadReport_Click(object sender, EventArgs e)
{
if (DropDownList_City.SelectedValue == "" || DropDownList_Company.SelectedValue == "" || DropDownList_Year.SelectedValue == "" || DropDownList_Month.SelectedValue == "")
{
Response.Write("<script language='javascript'>window.alert('请选择正确的城市、企业及年月');</script>");
}
else
{
GypPriceStatisticReport ReturnGypPriceStatisticReport = new GypPriceStatisticReport();
string ssdh = DropDownList_City.SelectedValue.Trim();
string qydh = DropDownList_Company.SelectedValue.Trim();
string StatisticTableID = DropDownList_StatisticReportName.SelectedValue.Trim();
string InputYearMonth = DropDownList_Year.SelectedValue.Trim() + DropDownList_Month.SelectedValue.Trim();
string GypYsDataTableName="";
if (StatisticTableID == "V201") //注意此处的V201的大小写要与数据库中的值一致
{
GypYsDataTableName = "GypCys";
}
else
{
GypYsDataTableName = "GypGys";
}
ReturnGypPriceStatisticReport = conn.GypGetStatisticReport(ssdh, qydh, StatisticTableID, "0001", InputYearMonth, GypYsDataTableName);
ReportDocument MyReport = new ReportDocument();
string ReportPath = Server.MapPath("../GypPrice/GypPriceStatisticReport.rpt");
MyReport.Load(ReportPath);
MyReport.SetDataSource(ReturnGypPriceStatisticReport);
//将报表中的年、月文本对象赋予DropDownList_Year和DropDownList_Month选择的值
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputYear"]).Text = DropDownList_Year.SelectedValue.Trim();
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputMonth"]).Text = DropDownList_Month.SelectedValue.Trim();
MyReport.PrintToPrinter(1, true, 0, 0);
CrystalReportViewer1.ReportSource = MyReport;
//CrystalReportViewer1.DataBind();
}
}
#6
上面的代码中倒数2-3是用来测试的。重发
//定义载入报表按钮Button_LoadReport的Click事件
protected void Button_LoadReport_Click(object sender, EventArgs e)
{
if (DropDownList_City.SelectedValue == "" || DropDownList_Company.SelectedValue == "" || DropDownList_Year.SelectedValue == "" || DropDownList_Month.SelectedValue == "")
{
Response.Write("<script language='javascript'>window.alert('请选择正确的城市、企业及年月');</script>");
}
else
{
GypPriceStatisticReport ReturnGypPriceStatisticReport = new GypPriceStatisticReport();
string ssdh = DropDownList_City.SelectedValue.Trim();
string qydh = DropDownList_Company.SelectedValue.Trim();
string StatisticTableID = DropDownList_StatisticReportName.SelectedValue.Trim();
string InputYearMonth = DropDownList_Year.SelectedValue.Trim() + DropDownList_Month.SelectedValue.Trim();
string GypYsDataTableName="";
if (StatisticTableID == "V201") //注意此处的V201的大小写要与数据库中的值一致
{
GypYsDataTableName = "GypCys";
}
else
{
GypYsDataTableName = "GypGys";
}
ReturnGypPriceStatisticReport = conn.GypGetStatisticReport(ssdh, qydh, StatisticTableID, "0001", InputYearMonth, GypYsDataTableName);
ReportDocument MyReport = new ReportDocument();
string ReportPath = Server.MapPath("../GypPrice/GypPriceStatisticReport.rpt");
MyReport.Load(ReportPath);
MyReport.SetDataSource(ReturnGypPriceStatisticReport);
//将报表中的年、月文本对象赋予DropDownList_Year和DropDownList_Month选择的值
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputYear"]).Text = DropDownList_Year.SelectedValue.Trim();
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputMonth"]).Text = DropDownList_Month.SelectedValue.Trim();
//CrystalReportViewer1.DataBind();
}
}
//定义载入报表按钮Button_LoadReport的Click事件
protected void Button_LoadReport_Click(object sender, EventArgs e)
{
if (DropDownList_City.SelectedValue == "" || DropDownList_Company.SelectedValue == "" || DropDownList_Year.SelectedValue == "" || DropDownList_Month.SelectedValue == "")
{
Response.Write("<script language='javascript'>window.alert('请选择正确的城市、企业及年月');</script>");
}
else
{
GypPriceStatisticReport ReturnGypPriceStatisticReport = new GypPriceStatisticReport();
string ssdh = DropDownList_City.SelectedValue.Trim();
string qydh = DropDownList_Company.SelectedValue.Trim();
string StatisticTableID = DropDownList_StatisticReportName.SelectedValue.Trim();
string InputYearMonth = DropDownList_Year.SelectedValue.Trim() + DropDownList_Month.SelectedValue.Trim();
string GypYsDataTableName="";
if (StatisticTableID == "V201") //注意此处的V201的大小写要与数据库中的值一致
{
GypYsDataTableName = "GypCys";
}
else
{
GypYsDataTableName = "GypGys";
}
ReturnGypPriceStatisticReport = conn.GypGetStatisticReport(ssdh, qydh, StatisticTableID, "0001", InputYearMonth, GypYsDataTableName);
ReportDocument MyReport = new ReportDocument();
string ReportPath = Server.MapPath("../GypPrice/GypPriceStatisticReport.rpt");
MyReport.Load(ReportPath);
MyReport.SetDataSource(ReturnGypPriceStatisticReport);
//将报表中的年、月文本对象赋予DropDownList_Year和DropDownList_Month选择的值
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputYear"]).Text = DropDownList_Year.SelectedValue.Trim();
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputMonth"]).Text = DropDownList_Month.SelectedValue.Trim();
//CrystalReportViewer1.DataBind();
}
}
#7
问到要害了,呵呵
#8
阿泰老师,帮我看看,这个怎么弄
#9
1:点打印和导出后页面数据丢失问题,因为每次操作都会重新连接数据源,所以要满足这个需要,我们采用缓存方案,防止多次连接数据库
//将处理好的报表对象缓存
Session["myRpt"]=MyReport;
CrystalReportViewer1.ReportSource = MyReport;
然后在 Page_Load事件里,增加代码段
if (Session["myRpt"]!=null)
{
CrystalReportViewer1.ReportSource = (ReportDocument)Session["myRpt"];
}
2:自定义打印和导出事件
拖2个服务器端button,双击进入,编写事件即可。
打印你已经写了,就是
MyReport.PrintToPrinter(1, true, 0, 0);
但是要注意MyReport要获取好,可以考虑从前面的session里取
导出也类似
myReport.ExportToDisk(ExportFormatType.PortableDocFormat, @"d:\ae0000.pdf");
#10
问题是:
这个好像是在服务器端的打印,而我需要客户端的打印,而且要实现可以选择IE客户端打印机的功能
这个也不能够让IE客户端自己选择文件保存地址
MyReport.PrintToPrinter(1, true, 0, 0);
这个好像是在服务器端的打印,而我需要客户端的打印,而且要实现可以选择IE客户端打印机的功能
myReport.ExportToDisk(ExportFormatType.PortableDocFormat, @"d:\ae0000.pdf");
这个也不能够让IE客户端自己选择文件保存地址
#11
另外,为何水晶报表自带的ToolBar中的打印和导出的click事件会重新连接数据源呢
在一个“拖2个服务器端button”,这两Button并不是水晶报表自带的ToolBar中的打印和导出按钮。
而我的意思是能否自定义水晶报表自带的ToolBar中的打印和导出按钮的click事件
在一个“拖2个服务器端button”,这两Button并不是水晶报表自带的ToolBar中的打印和导出按钮。
而我的意思是能否自定义水晶报表自带的ToolBar中的打印和导出按钮的click事件
#12
1:HTTP是无状态的
2:基本上认为是不可以的。
当然,你可以尝试去修改水晶报表的工具条脚本,但是这样带来的问题是,脚本是通用的,你的一次修改可能会影响其他报表的打印等动作。
#13
1:应该是说从服务器端发起的打印任务,这个可以打到任何一台服务器能连上的共享打印机上。
而且要做到选择,也是可以的。
myReport.PrintOptions.PrinterName = "打印机名称或\\打印机名称";
从这句看出,你可以指定目标打印机的,所以你可以做一个打印机列表,让用户去选。
这个做起来是有点麻烦,所以很多人会放弃这个方案,虽然这确实是个好的且被证明为有效的方案
2:让用户选保存路径,也是可以的,也有好几种方法
比如说,这句代码后面加上句: Response.Redirect("pdf的位置"); 用户就可以下载到本地了。
#14
1:应该是说从服务器端发起的打印任务,这个可以打到任何一台服务器能连上的共享打印机上。
而且要做到选择,也是可以的。
myReport.PrintOptions.PrinterName = "打印机名称或\\打印机名称";
从这句看出,你可以指定目标打印机的,所以你可以做一个打印机列表,让用户去选。
这个做起来是有点麻烦,所以很多人会放弃这个方案,虽然这确实是个好的且被证明为有效的方案
这个做打印机列表好像不现实,因为我的用户是通过互联网来访问这个页面的,不可能实现客户端的打印机能够让网站服务器端共享打印,这个打印机的列表也无法建立,用户的IP地址是随机的,某些内网用户的代理服务器及防火墙都会有限制
而且要做到选择,也是可以的。
myReport.PrintOptions.PrinterName = "打印机名称或\\打印机名称";
从这句看出,你可以指定目标打印机的,所以你可以做一个打印机列表,让用户去选。
这个做起来是有点麻烦,所以很多人会放弃这个方案,虽然这确实是个好的且被证明为有效的方案
这个做打印机列表好像不现实,因为我的用户是通过互联网来访问这个页面的,不可能实现客户端的打印机能够让网站服务器端共享打印,这个打印机的列表也无法建立,用户的IP地址是随机的,某些内网用户的代理服务器及防火墙都会有限制
#15
楼主应该事先声明这些条件,可以少一些往复。
公网打印,就只能用工具条了。
公网打印,就只能用工具条了。
#16
另外,请问一个问题,如果用vs2005自带的Crystal Reports for vs 2005 设计的报表进行网络部署的话,在Web中使用是不是有使用次数的限制,如果有,怎么破解
#17
不好意思,麻烦您了
#19
阿泰都帮你解决了
问题原因就是,你是在按钮点击的时候给报表绑定的值,
但是页面刷新后,执行的page_load,没有执行按钮单击事件,所以没有绑定值给报表。
也就无法显示数据
所以一般报表页面都是不加
isPostBack这个判断的
#20
MyReport.PrintToPrinter(1, true, 0, 0);
这样打印,在客户端也可以,只要连接的有打印机
导出的话,我的一般做法是导出到服务器上,然后提供下载
给你个下载方法
直接Response.Redirect("pdf的位置"); 貌似有些时候会打开,而不是提示保存
我一般是加一个download画面,然后代码里面写这些代码
导出成功后,然后跳转到这个画面,传地址参数
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using System.Reflection;
using System.Diagnostics;
public partial class WebForms_Hospital_Default :PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
string strPath = Request["Path"].ToString().Trim();
DownloadFile(Page.Response, strPath);
}
catch (Exception ex)
{
this.ShowMessage(ex.Message);
}
}
#region 下载服务器上的文件
/// <summary>
/// 下载服务器上的文件
/// </summary>
/// <param name="PageResponse">程序中可以设置参数:HttpResponse ht=Page.Response;</param>
/// <param name="serverPath">服务器上的文件路径</param>
public void DownloadFile(HttpResponse response, string serverPath)
{
FileStream fs = null;
try
{
fs = File.OpenRead(serverPath);
byte[] buffer = new byte[1024];
long count = 1024;
response.Buffer = true;
response.AddHeader("Connection", "Keep-Alive");
response.ContentType = "application/octet-stream";
response.AddHeader("Content-Disposition", "attachment;filename=" + Path.GetFileName(serverPath));//下载时要保存的默认文件名
response.AddHeader("Content-Length", fs.Length.ToString());
while (count == 1024)
{
count = fs.Read(buffer, 0, 1024);
response.BinaryWrite(buffer);
}
}
catch
{
}
finally
{
fs.Close();
}
}
#endregion
}
#21
记得有次看阿泰的回复,好像是修改注册表
默认好像是打印30次,修改注册表可以设置多的次数,比如1000
忘了在哪设了
等阿泰
#22
VS自带的版本默认75次打印任务,75次后可以重启IIS即可重新计数。
具体为修改注册表下面两个键的值。
[HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\InProcServer]
修改"PrintJobLimit"="1000"
[HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\Server]
修改"PrintJobLimit"="1000"
但是定期重启IIS是不可避免的,之前看到一些系统是每天晚上系统空闲时会自动重启服务器的。
当然,最好是换成独立版本。如果是用户比较多的话。
具体为修改注册表下面两个键的值。
[HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\InProcServer]
修改"PrintJobLimit"="1000"
[HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\Server]
修改"PrintJobLimit"="1000"
但是定期重启IIS是不可避免的,之前看到一些系统是每天晚上系统空闲时会自动重启服务器的。
当然,最好是换成独立版本。如果是用户比较多的话。
#23
收藏
#24
#25
说的太好了,刚接触 以后多多学习
#1
这个问题没有碰到,我用的是XtraReports(一个第三方控件的报表),帮顶!
#2
整页代码贴出来 :)
#3
#4
这个要收费吗
#5
//定义载入报表按钮Button_LoadReport的Click事件
protected void Button_LoadReport_Click(object sender, EventArgs e)
{
if (DropDownList_City.SelectedValue == "" || DropDownList_Company.SelectedValue == "" || DropDownList_Year.SelectedValue == "" || DropDownList_Month.SelectedValue == "")
{
Response.Write("<script language='javascript'>window.alert('请选择正确的城市、企业及年月');</script>");
}
else
{
GypPriceStatisticReport ReturnGypPriceStatisticReport = new GypPriceStatisticReport();
string ssdh = DropDownList_City.SelectedValue.Trim();
string qydh = DropDownList_Company.SelectedValue.Trim();
string StatisticTableID = DropDownList_StatisticReportName.SelectedValue.Trim();
string InputYearMonth = DropDownList_Year.SelectedValue.Trim() + DropDownList_Month.SelectedValue.Trim();
string GypYsDataTableName="";
if (StatisticTableID == "V201") //注意此处的V201的大小写要与数据库中的值一致
{
GypYsDataTableName = "GypCys";
}
else
{
GypYsDataTableName = "GypGys";
}
ReturnGypPriceStatisticReport = conn.GypGetStatisticReport(ssdh, qydh, StatisticTableID, "0001", InputYearMonth, GypYsDataTableName);
ReportDocument MyReport = new ReportDocument();
string ReportPath = Server.MapPath("../GypPrice/GypPriceStatisticReport.rpt");
MyReport.Load(ReportPath);
MyReport.SetDataSource(ReturnGypPriceStatisticReport);
//将报表中的年、月文本对象赋予DropDownList_Year和DropDownList_Month选择的值
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputYear"]).Text = DropDownList_Year.SelectedValue.Trim();
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputMonth"]).Text = DropDownList_Month.SelectedValue.Trim();
MyReport.PrintToPrinter(1, true, 0, 0);
CrystalReportViewer1.ReportSource = MyReport;
//CrystalReportViewer1.DataBind();
}
}
#6
上面的代码中倒数2-3是用来测试的。重发
//定义载入报表按钮Button_LoadReport的Click事件
protected void Button_LoadReport_Click(object sender, EventArgs e)
{
if (DropDownList_City.SelectedValue == "" || DropDownList_Company.SelectedValue == "" || DropDownList_Year.SelectedValue == "" || DropDownList_Month.SelectedValue == "")
{
Response.Write("<script language='javascript'>window.alert('请选择正确的城市、企业及年月');</script>");
}
else
{
GypPriceStatisticReport ReturnGypPriceStatisticReport = new GypPriceStatisticReport();
string ssdh = DropDownList_City.SelectedValue.Trim();
string qydh = DropDownList_Company.SelectedValue.Trim();
string StatisticTableID = DropDownList_StatisticReportName.SelectedValue.Trim();
string InputYearMonth = DropDownList_Year.SelectedValue.Trim() + DropDownList_Month.SelectedValue.Trim();
string GypYsDataTableName="";
if (StatisticTableID == "V201") //注意此处的V201的大小写要与数据库中的值一致
{
GypYsDataTableName = "GypCys";
}
else
{
GypYsDataTableName = "GypGys";
}
ReturnGypPriceStatisticReport = conn.GypGetStatisticReport(ssdh, qydh, StatisticTableID, "0001", InputYearMonth, GypYsDataTableName);
ReportDocument MyReport = new ReportDocument();
string ReportPath = Server.MapPath("../GypPrice/GypPriceStatisticReport.rpt");
MyReport.Load(ReportPath);
MyReport.SetDataSource(ReturnGypPriceStatisticReport);
//将报表中的年、月文本对象赋予DropDownList_Year和DropDownList_Month选择的值
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputYear"]).Text = DropDownList_Year.SelectedValue.Trim();
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputMonth"]).Text = DropDownList_Month.SelectedValue.Trim();
//CrystalReportViewer1.DataBind();
}
}
//定义载入报表按钮Button_LoadReport的Click事件
protected void Button_LoadReport_Click(object sender, EventArgs e)
{
if (DropDownList_City.SelectedValue == "" || DropDownList_Company.SelectedValue == "" || DropDownList_Year.SelectedValue == "" || DropDownList_Month.SelectedValue == "")
{
Response.Write("<script language='javascript'>window.alert('请选择正确的城市、企业及年月');</script>");
}
else
{
GypPriceStatisticReport ReturnGypPriceStatisticReport = new GypPriceStatisticReport();
string ssdh = DropDownList_City.SelectedValue.Trim();
string qydh = DropDownList_Company.SelectedValue.Trim();
string StatisticTableID = DropDownList_StatisticReportName.SelectedValue.Trim();
string InputYearMonth = DropDownList_Year.SelectedValue.Trim() + DropDownList_Month.SelectedValue.Trim();
string GypYsDataTableName="";
if (StatisticTableID == "V201") //注意此处的V201的大小写要与数据库中的值一致
{
GypYsDataTableName = "GypCys";
}
else
{
GypYsDataTableName = "GypGys";
}
ReturnGypPriceStatisticReport = conn.GypGetStatisticReport(ssdh, qydh, StatisticTableID, "0001", InputYearMonth, GypYsDataTableName);
ReportDocument MyReport = new ReportDocument();
string ReportPath = Server.MapPath("../GypPrice/GypPriceStatisticReport.rpt");
MyReport.Load(ReportPath);
MyReport.SetDataSource(ReturnGypPriceStatisticReport);
//将报表中的年、月文本对象赋予DropDownList_Year和DropDownList_Month选择的值
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputYear"]).Text = DropDownList_Year.SelectedValue.Trim();
((TextObject)MyReport.ReportDefinition.ReportObjects["Text_InputMonth"]).Text = DropDownList_Month.SelectedValue.Trim();
//CrystalReportViewer1.DataBind();
}
}
#7
问到要害了,呵呵
#8
阿泰老师,帮我看看,这个怎么弄
#9
1:点打印和导出后页面数据丢失问题,因为每次操作都会重新连接数据源,所以要满足这个需要,我们采用缓存方案,防止多次连接数据库
//将处理好的报表对象缓存
Session["myRpt"]=MyReport;
CrystalReportViewer1.ReportSource = MyReport;
然后在 Page_Load事件里,增加代码段
if (Session["myRpt"]!=null)
{
CrystalReportViewer1.ReportSource = (ReportDocument)Session["myRpt"];
}
2:自定义打印和导出事件
拖2个服务器端button,双击进入,编写事件即可。
打印你已经写了,就是
MyReport.PrintToPrinter(1, true, 0, 0);
但是要注意MyReport要获取好,可以考虑从前面的session里取
导出也类似
myReport.ExportToDisk(ExportFormatType.PortableDocFormat, @"d:\ae0000.pdf");
#10
问题是:
这个好像是在服务器端的打印,而我需要客户端的打印,而且要实现可以选择IE客户端打印机的功能
这个也不能够让IE客户端自己选择文件保存地址
MyReport.PrintToPrinter(1, true, 0, 0);
这个好像是在服务器端的打印,而我需要客户端的打印,而且要实现可以选择IE客户端打印机的功能
myReport.ExportToDisk(ExportFormatType.PortableDocFormat, @"d:\ae0000.pdf");
这个也不能够让IE客户端自己选择文件保存地址
#11
另外,为何水晶报表自带的ToolBar中的打印和导出的click事件会重新连接数据源呢
在一个“拖2个服务器端button”,这两Button并不是水晶报表自带的ToolBar中的打印和导出按钮。
而我的意思是能否自定义水晶报表自带的ToolBar中的打印和导出按钮的click事件
在一个“拖2个服务器端button”,这两Button并不是水晶报表自带的ToolBar中的打印和导出按钮。
而我的意思是能否自定义水晶报表自带的ToolBar中的打印和导出按钮的click事件
#12
1:HTTP是无状态的
2:基本上认为是不可以的。
当然,你可以尝试去修改水晶报表的工具条脚本,但是这样带来的问题是,脚本是通用的,你的一次修改可能会影响其他报表的打印等动作。
#13
1:应该是说从服务器端发起的打印任务,这个可以打到任何一台服务器能连上的共享打印机上。
而且要做到选择,也是可以的。
myReport.PrintOptions.PrinterName = "打印机名称或\\打印机名称";
从这句看出,你可以指定目标打印机的,所以你可以做一个打印机列表,让用户去选。
这个做起来是有点麻烦,所以很多人会放弃这个方案,虽然这确实是个好的且被证明为有效的方案
2:让用户选保存路径,也是可以的,也有好几种方法
比如说,这句代码后面加上句: Response.Redirect("pdf的位置"); 用户就可以下载到本地了。
#14
1:应该是说从服务器端发起的打印任务,这个可以打到任何一台服务器能连上的共享打印机上。
而且要做到选择,也是可以的。
myReport.PrintOptions.PrinterName = "打印机名称或\\打印机名称";
从这句看出,你可以指定目标打印机的,所以你可以做一个打印机列表,让用户去选。
这个做起来是有点麻烦,所以很多人会放弃这个方案,虽然这确实是个好的且被证明为有效的方案
这个做打印机列表好像不现实,因为我的用户是通过互联网来访问这个页面的,不可能实现客户端的打印机能够让网站服务器端共享打印,这个打印机的列表也无法建立,用户的IP地址是随机的,某些内网用户的代理服务器及防火墙都会有限制
而且要做到选择,也是可以的。
myReport.PrintOptions.PrinterName = "打印机名称或\\打印机名称";
从这句看出,你可以指定目标打印机的,所以你可以做一个打印机列表,让用户去选。
这个做起来是有点麻烦,所以很多人会放弃这个方案,虽然这确实是个好的且被证明为有效的方案
这个做打印机列表好像不现实,因为我的用户是通过互联网来访问这个页面的,不可能实现客户端的打印机能够让网站服务器端共享打印,这个打印机的列表也无法建立,用户的IP地址是随机的,某些内网用户的代理服务器及防火墙都会有限制
#15
楼主应该事先声明这些条件,可以少一些往复。
公网打印,就只能用工具条了。
公网打印,就只能用工具条了。
#16
另外,请问一个问题,如果用vs2005自带的Crystal Reports for vs 2005 设计的报表进行网络部署的话,在Web中使用是不是有使用次数的限制,如果有,怎么破解
#17
不好意思,麻烦您了
#18
#19
阿泰都帮你解决了
问题原因就是,你是在按钮点击的时候给报表绑定的值,
但是页面刷新后,执行的page_load,没有执行按钮单击事件,所以没有绑定值给报表。
也就无法显示数据
所以一般报表页面都是不加
isPostBack这个判断的
#20
MyReport.PrintToPrinter(1, true, 0, 0);
这样打印,在客户端也可以,只要连接的有打印机
导出的话,我的一般做法是导出到服务器上,然后提供下载
给你个下载方法
直接Response.Redirect("pdf的位置"); 貌似有些时候会打开,而不是提示保存
我一般是加一个download画面,然后代码里面写这些代码
导出成功后,然后跳转到这个画面,传地址参数
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using System.Reflection;
using System.Diagnostics;
public partial class WebForms_Hospital_Default :PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
string strPath = Request["Path"].ToString().Trim();
DownloadFile(Page.Response, strPath);
}
catch (Exception ex)
{
this.ShowMessage(ex.Message);
}
}
#region 下载服务器上的文件
/// <summary>
/// 下载服务器上的文件
/// </summary>
/// <param name="PageResponse">程序中可以设置参数:HttpResponse ht=Page.Response;</param>
/// <param name="serverPath">服务器上的文件路径</param>
public void DownloadFile(HttpResponse response, string serverPath)
{
FileStream fs = null;
try
{
fs = File.OpenRead(serverPath);
byte[] buffer = new byte[1024];
long count = 1024;
response.Buffer = true;
response.AddHeader("Connection", "Keep-Alive");
response.ContentType = "application/octet-stream";
response.AddHeader("Content-Disposition", "attachment;filename=" + Path.GetFileName(serverPath));//下载时要保存的默认文件名
response.AddHeader("Content-Length", fs.Length.ToString());
while (count == 1024)
{
count = fs.Read(buffer, 0, 1024);
response.BinaryWrite(buffer);
}
}
catch
{
}
finally
{
fs.Close();
}
}
#endregion
}
#21
记得有次看阿泰的回复,好像是修改注册表
默认好像是打印30次,修改注册表可以设置多的次数,比如1000
忘了在哪设了
等阿泰
#22
VS自带的版本默认75次打印任务,75次后可以重启IIS即可重新计数。
具体为修改注册表下面两个键的值。
[HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\InProcServer]
修改"PrintJobLimit"="1000"
[HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\Server]
修改"PrintJobLimit"="1000"
但是定期重启IIS是不可避免的,之前看到一些系统是每天晚上系统空闲时会自动重启服务器的。
当然,最好是换成独立版本。如果是用户比较多的话。
具体为修改注册表下面两个键的值。
[HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\InProcServer]
修改"PrintJobLimit"="1000"
[HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\Server]
修改"PrintJobLimit"="1000"
但是定期重启IIS是不可避免的,之前看到一些系统是每天晚上系统空闲时会自动重启服务器的。
当然,最好是换成独立版本。如果是用户比较多的话。
#23
收藏
#24
#25
说的太好了,刚接触 以后多多学习