水晶报表多页问题 [英] Crystal Report multiple page problem
本文介绍了水晶报表多页问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用Crystal Report和CrystalReportViewer显示报告.工作正常.但是,如果数据很大,并且花费的时间超过页面上的数据,则仅显示第一页.如何显示所有页面.这是我的代码.
注意:我正在使用asp.net,c#
受保护的 无效 Page_Load(对象发件人,EventArgs e)
{
字符串 ReportName = " ;
字符串 Parameter1 = " ;
ReportName =会话[" ].ToString();
Parameter1 = Session [" ].ToString();
ReportDocument rptDoc = 新 ReportDocument();
尝试
{
rptDoc = ShowReport(ReportName,Parameter1);
CrystalReportViewer1.ReportSource = rptDoc;
CrystalReportViewer1.RefreshReport();
CrystalReportViewer1.Visible = true ;
CrystalReportViewer1.DataBind();
}
捕获(例外)
{
}
}
#region实例化
私有 ParameterValues crParameterValues = 新 ParameterValues();
私有 ParameterDiscreteValue crParameterDiscreteValue = 新 ParameterDiscreteValue();
私有 ReportDocument cryRpt = 新 ReportDocument();
#endregion
#region声明
私有 字符串 ServerName = ConfigurationManager.AppSettings [" 服务器名称"].ToString();
私有 字符串 DatabaseName = ConfigurationManager.AppSettings [" 数据库名称"].ToString();
私有 字符串 UserName = ConfigurationManager.AppSettings [" 用户名"].ToString();
私有 字符串密码= ConfigurationManager.AppSettings [" 密码"].ToString();
私有 ParameterFieldDefinitions crParameterFieldDefinitions;
私有 ParameterFieldDefinition crParameterFieldDefinition;
#endregion
#region DatabaseLogonInfo
ReportDocument DatabaseLogonInfo()
{
ReportDocument cryRpt = 新 ReportDocument();
尝试
{
// 字符串ServerName = ConfigurationManager.AppSettings ["servername"].ToString();
// 字符串DatabaseName = ConfigurationManager.AppSettings ["databasename"].ToString();
// 字符串UserName = ConfigurationManager.AppSettings ["username"].ToString();
// 字符串密码= ConfigurationManager.AppSettings ["password"].ToString();
cryRpt.SetDatabaseLogon(UserName,Password,ServerName,DatabaseName);
}
捕获(例外)
{
扔 ex;
}
返回 cryRpt;
}
#endregion
#region对一个字符串类型的Parametar执行报告
公共 ReportDocument ShowReport(字符串 ReportName,字符串 Parameter1)
{
尝试
{
// cryRpt.Refresh();
cryRpt.Load(ReportName);
cryRpt.SetDatabaseLogon(UserName,Password,ServerName,DatabaseName);
crParameterValues.Clear();
crParameterDiscreteValue.Value = Parameter1; // 像Parameter1
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions [" ];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
}
捕获(例外)
{
扔 ex;
// ShowReport(@"default_report.rpt");
}
// CleareParameter();
返回 cryRpt;
}
#endregion
解决方案
检查这些链接
打印报告我得到了一个额外的空白页 [ ^ ]
Crystal报表-获取报表中生成的空白数据 [ ^ ]
水晶报告-无法获取输出 [ MSDN- [PrintDocument.BeginPrint事件]
[ ^ ]
参考链接:- http://msdn.microsoft.com/en-us/library/ms996472.aspx [ ^ ]
Hi,
I can display a report by using Crystal Report and CrystalReportViewer. It working nice. But if the data are large and it takes more than on page then it shows only the first page. How can I show all the pages. Here is my code.
NB: I am using asp.net, c#
protected void Page_Load(object sender, EventArgs e)
{
string ReportName="";
string Parameter1="";
ReportName = Session["ReportName"].ToString();
Parameter1 = Session["Parameter1"].ToString();
ReportDocument rptDoc = new ReportDocument();
try
{
rptDoc = ShowReport(ReportName, Parameter1);
CrystalReportViewer1.ReportSource = rptDoc;
CrystalReportViewer1.RefreshReport();
CrystalReportViewer1.Visible = true;
CrystalReportViewer1.DataBind();
}
catch (Exception ex)
{
}
}
#region Instantiate
private ParameterValues crParameterValues = new ParameterValues();
private ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
private ReportDocument cryRpt = new ReportDocument();
#endregion
#region Declaration
private string ServerName = ConfigurationManager.AppSettings["ServerName"].ToString();
private string DatabaseName = ConfigurationManager.AppSettings["DatabaseName"].ToString();
private string UserName = ConfigurationManager.AppSettings["UserName"].ToString();
private string Password = ConfigurationManager.AppSettings["Password"].ToString();
private ParameterFieldDefinitions crParameterFieldDefinitions;
private ParameterFieldDefinition crParameterFieldDefinition;
#endregion
#region DatabaseLogonInfo
ReportDocument DatabaseLogonInfo()
{
ReportDocument cryRpt = new ReportDocument();
try
{
//string ServerName = ConfigurationManager.AppSettings["servername"].ToString();
//string DatabaseName = ConfigurationManager.AppSettings["databasename"].ToString();
//string UserName = ConfigurationManager.AppSettings["username"].ToString();
//string Password = ConfigurationManager.AppSettings["password"].ToString();
cryRpt.SetDatabaseLogon(UserName, Password, ServerName, DatabaseName);
}
catch (Exception ex)
{
throw ex;
}
return cryRpt;
}
#endregion
#region Execute report For one String type Parametar
public ReportDocument ShowReport(string ReportName, string Parameter1)
{
try
{
//cryRpt.Refresh();
cryRpt.Load(ReportName);
cryRpt.SetDatabaseLogon(UserName, Password, ServerName, DatabaseName);
crParameterValues.Clear();
crParameterDiscreteValue.Value = Parameter1;// as like Parameter1
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["@Parameter1"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
}
catch (Exception ex)
{
throw ex;
//ShowReport(@"default_report.rpt");
}
//CleareParameter();
return cryRpt;
}
#endregion
解决方案
Check these links
Printing a reports I am getting a extra empty page[^]
Crystal reports - getting blank data generated in reports[^]
Crystal report - not getting the output[^]
If your report could span more than one page, then you need to keep track of a few details, such as the current page number and the current row of data, as each page results in its own call to the PrintPage event handler. In each case, creating a variable that exists outside of the event handler code will allow you to remember your current position between calls to PrintPage.
Always remember to reset these values before every time you print, or else your second printing won''t start with a page number of 1. The best place to reset these values is in the BeginPrint event of the PrintDocument.
MSDN-[PrintDocument.BeginPrint Event]
[^]
Reference Link :- http://msdn.microsoft.com/en-us/library/ms996472.aspx[^]
这篇关于水晶报表多页问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文