怎样给reportViewer报表组件指定数据源?
4个回答
ZESTRON
2024-09-04 广告
2024-09-04 广告
表界面分析在材料科学及化学领域占据核心地位,它深入探索物质表面与界面的微观结构、化学组成及相互作用。通过电商平台射线光电子能谱(电商平台PS)、扫描电子显微镜(SEM)及原子力显微镜(AFM)等先进技术手段,我们Dr. O.K. Wack ...
点击进入详情页
本回答由ZESTRON提供
展开全部
Rdlc可以自定义数据源,你可以将查询结果绑定到rdlc报表中.这应该可以解决你的第一个问题.
第二个问题,你应该设置InteractiveHeight,和InteractiveWidth属性,以满足你需要纸张大小.还有注意一下上下边距大小.这往往会导致多打一张空白页出来,我以前也试过这个问题.
第二个问题,你应该设置InteractiveHeight,和InteractiveWidth属性,以满足你需要纸张大小.还有注意一下上下边距大小.这往往会导致多打一张空白页出来,我以前也试过这个问题.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
/// <summary>
/// 生成报表数据
/// </summary>
private void CreateReport()
{
string bgDate = txtBegin.Text.Trim().Replace("-", "");
string edDate = txtEnd.Text.Trim().Replace("-", "");
DataTable dt = OPReportBLL.GetClientTargetList(ddlYear.SelectedValue + ddlMonth.SelectedValue + ddlWeek.SelectedValue.Substring(0, 1));
this.RptView.LocalReport.ReportPath = "Report\\RptFile\\ADCClientTarget.rdlc";
this.RptView.LocalReport.DataSources.Clear();
this.RptView.LocalReport.DataSources.Add(new ReportDataSource("ADCClientTarget_ADCClientTarget", dt));
this.SetReportParameters(this.RptView.LocalReport);
this.RptView.DataBind();
}
/// <summary>
/// 设置报表参数
/// </summary>
private void SetReportParameters(Report localReport)
{
ReportParameter[] parameters = new ReportParameter[1];
parameters[0] = new ReportParameter("time", "统计区间:" + txtBegin.Text + "至" + txtEnd.Text);
localReport.SetParameters(parameters);
}
/// 生成报表数据
/// </summary>
private void CreateReport()
{
string bgDate = txtBegin.Text.Trim().Replace("-", "");
string edDate = txtEnd.Text.Trim().Replace("-", "");
DataTable dt = OPReportBLL.GetClientTargetList(ddlYear.SelectedValue + ddlMonth.SelectedValue + ddlWeek.SelectedValue.Substring(0, 1));
this.RptView.LocalReport.ReportPath = "Report\\RptFile\\ADCClientTarget.rdlc";
this.RptView.LocalReport.DataSources.Clear();
this.RptView.LocalReport.DataSources.Add(new ReportDataSource("ADCClientTarget_ADCClientTarget", dt));
this.SetReportParameters(this.RptView.LocalReport);
this.RptView.DataBind();
}
/// <summary>
/// 设置报表参数
/// </summary>
private void SetReportParameters(Report localReport)
{
ReportParameter[] parameters = new ReportParameter[1];
parameters[0] = new ReportParameter("time", "统计区间:" + txtBegin.Text + "至" + txtEnd.Text);
localReport.SetParameters(parameters);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class Demo : Form
{
private DataTable LoadEmployeesData()
{
DataSet dataSet = new DataSet();
dataSet.ReadXml("employees.xml");
return dataSet.Tables[0];
}
private DataTable LoadDepartmentsData()
{
DataSet dataSet = new DataSet();
dataSet.ReadXml("departments.xml");
return dataSet.Tables[0];
}
void DemoDrillthroughEventHandler(object sender, DrillthroughEventArgs e)
{
LocalReport localReport = (LocalReport)e.Report;
localReport.DataSources.Add(new ReportDataSource("Employees", LoadEmployeesData()));
}
public Demo()
{
this.Text = "Report Control Demo";
this.ClientSize = new System.Drawing.Size(950, 600);
ReportViewer reportViewer = new ReportViewer();
// Set Processing Mode.
reportViewer.ProcessingMode = ProcessingMode.Local;
// Set RDL file.
reportViewer.LocalReport.ReportPath = "Departments.rdlc";
// Supply a DataTable corresponding to each report data source.
reportViewer.LocalReport.DataSources.Add(
new ReportDataSource("Departments", LoadDepartmentsData()));
// Add a handler for drillthrough.
reportViewer.Drillthrough += new DrillthroughEventHandler(DemoDrillthroughEventHandler);
// Add the reportviewer to the form.
reportViewer.Dock = DockStyle.Fill;
this.Controls.Add(reportViewer);
// Process and render the report.
reportViewer.RefreshReport();
}
[STAThread]
public static int Main(string[] args)
{
Application.Run(new Demo());
return 0;
}
}
{
private DataTable LoadEmployeesData()
{
DataSet dataSet = new DataSet();
dataSet.ReadXml("employees.xml");
return dataSet.Tables[0];
}
private DataTable LoadDepartmentsData()
{
DataSet dataSet = new DataSet();
dataSet.ReadXml("departments.xml");
return dataSet.Tables[0];
}
void DemoDrillthroughEventHandler(object sender, DrillthroughEventArgs e)
{
LocalReport localReport = (LocalReport)e.Report;
localReport.DataSources.Add(new ReportDataSource("Employees", LoadEmployeesData()));
}
public Demo()
{
this.Text = "Report Control Demo";
this.ClientSize = new System.Drawing.Size(950, 600);
ReportViewer reportViewer = new ReportViewer();
// Set Processing Mode.
reportViewer.ProcessingMode = ProcessingMode.Local;
// Set RDL file.
reportViewer.LocalReport.ReportPath = "Departments.rdlc";
// Supply a DataTable corresponding to each report data source.
reportViewer.LocalReport.DataSources.Add(
new ReportDataSource("Departments", LoadDepartmentsData()));
// Add a handler for drillthrough.
reportViewer.Drillthrough += new DrillthroughEventHandler(DemoDrillthroughEventHandler);
// Add the reportviewer to the form.
reportViewer.Dock = DockStyle.Fill;
this.Controls.Add(reportViewer);
// Process and render the report.
reportViewer.RefreshReport();
}
[STAThread]
public static int Main(string[] args)
{
Application.Run(new Demo());
return 0;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询