CR:CrystalReportViewer
来源:互联网 发布:net.sf.json 编辑:程序博客网 时间:2024/06/06 00:29
//报表对象
ReportDocument rptDoc = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
// 数据库登陆信息
TableLogOnInfo logInfo = new TableLogOnInfo();
// 连接字符
string strConn = ConfigurationManager.ConnectionStrings["DataSqlConnection"].ConnectionString;
string[] parma = strConn.Split(';');
// 设置数据连接
for (int index = 0; index < parma.Length; index++)
{
if (parma[index].Contains("server"))
{
logInfo.ConnectionInfo.ServerName = parma[index].Split('=')[1];
}
else if (parma[index].Contains("database"))
{
logInfo.ConnectionInfo.DatabaseName = parma[index].Split('=')[1];
}
else if (parma[index].Contains("user id"))
{
logInfo.ConnectionInfo.UserID = parma[index].Split('=')[1];
}
else if (parma[index].Contains("password"))
{
logInfo.ConnectionInfo.Password = parma[index].Split('=')[1];
}
}
//报表名称
string strRpt = "报表名称";
// 报表地址
string strPath = Server.MapPath(strRpt + ".rpt");
// 读取报表
rptDoc.Load(strPath);
// 设置报表变量
SetParamFields(strRpt);
// 设置登陆信息
rptDoc.Database.Tables[0].ApplyLogOnInfo(logInfo);
// 设置数据
rptView.ReportSource = rptDoc;
}
//注销报表
private void Page_Unload(object sender, EventArgs e)
{
rptDoc.Close();
rptDoc.Dispose();
}
/// <summary>
/// 设置参数
/// </summary>
/// <param name="strRptName"></param>
private void SetParamFields(string strRptName)
{
Hashtable paramList = getParamsList(strRptName);
if (paramList.Count > 0)
{
// 变量
ParameterFields paramFields = new ParameterFields();
IDictionaryEnumerator it = paramList.GetEnumerator();
while (it.MoveNext())
{
// 变量Field
ParameterField field = new ParameterField();
field.ParameterFieldName = it.Key.ToString();
// 变量值
ParameterDiscreteValue value = new ParameterDiscreteValue();
value.Value = Request.QueryString[it.Key.ToString()];
field.CurrentValues.Add(value);
paramFields.Add(field);
}
// 设置变量
rptView.ParameterFieldInfo = paramFields;
}
}
public static Hashtable getParamsList(string strRptID)
{
Hashtable paramsList = new Hashtable();
try
{
string filename = HttpContext.Current.Server.MapPath("RptParamFile.xml");
if (!File.Exists(filename)) throw new Exception("xmltext's file not found!");
XmlDocument xdoc = new XmlDocument();
xdoc.Load(filename);
string strNodepath = "/ReportID/" + strRptID + "/params";
XmlNode child = xdoc.SelectSingleNode(strNodepath);
if (child != null)
{
foreach (XmlNode node in child.ChildNodes)
{
paramsList.Add(node.Attributes["paramName"].Value, node.Attributes["type"].Value);
}
}
}
catch
{
}
return paramsList;
}
- CR:CrystalReportViewer
- cr
- cr
- CrystalReportViewer运用
- CrystalReportViewer 成员
- CrystalReportViewer的属性
- VS2005 crystalReportviewer 打印问题
- CR keys
- CR块
- 新建CR
- CR LIST
- CrystalReportViewer的鼠标滚轮支持
- CrystalReportViewer 打印功能ActiveX pdf
- 合并CR:将某CR挂到另一个CR下
- 如何向 CrystalReportViewer 和 ReportDocument 传递参数
- 如何向 CrystalReportViewer 和 ReportDocument 传递参数
- 水晶报表CrystalReportViewer之“创建控件错误”
- 如何向 CrystalReportViewer 和 ReportDocument 传递参数
- 求救ing
- iPhone 开发调用 phone,sms,email,safari 浏览器的方法
- reshape列优先
- web中的一些怪异
- 求救ing
- CR:CrystalReportViewer
- settings
- Reducing CPU usage in Adobe AIR
- android service
- Windows Virtualbox虚拟Ubuntu共享文件夹
- 稀疏矩阵相加(十字链表存储)
- maximo中直接应用得到数据库联接
- 超级解压 V1.0
- Cygwin 使用 svn 命令导出中文文件名或目录