Reports using microsoft viewer

谁都会走 提交于 2019-12-12 04:21:07

问题


How to create parametrized reports using microsoft report viewer?


回答1:


Put more details in your question, but as i understand the MSDN ReportViewer Controls will be very nice to you learn more by yourself.




回答2:


Check out http://www.youtube.com/watch?v=sXJmRHgSAS8&feature=related




回答3:


For one thing, I would avoid the Microsoft report viewer control. Just use a browser control, and browse to the report, passing in the parameters in the URL like you would when using a browser.

This is much better for many reasons.

  1. The MS Report Viewer Control has a lot of bugs that you will be stuck with.
  2. The browser and the report viewer render the reports differently (slightly) such as with margins etc. So you will have to tweak most of your reports if you ever switch to a web application and need to use the browser to access reports. This brings me to the next issue . . .
  3. If you ever need to go to a web application, you will need to reimplement how you call reports, pass parameters, etc. instead of just using the browser functionality you already have created (you access the reports differently using the control vs. using a browser)

Otherwise, if you truly want to use the Report Viewer control, here is a sample (using .NET 2.0):

    ReportViewer rvReportViewerControl = new ReportViewer();
   rvReportViewerControl.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
    rvReportViewerControl.ServerReport.ReportServerUrl = new Uri("http://<SERVERNAME>/ReportServer");
    rvReportViewerControl.ServerReport.ReportPath = "<FOLDER PATH TO REPORTS>");
    rvReportViewerControl.ShowParameterPrompts = false;
    Microsoft.Reporting.WinForms.ReportParameterInfoCollection rpInfoCollection = rvReportViewerControl.ServerReport.GetParameters();
    if (rpInfoCollection.Count > 0)
    {
         List<ReportParameter> paramList = new List<ReportParameter>();

         foreach (ReportParameterInfo reportParameter in rpInfoCollection)
         {
              string parameterName = reportParameter.Name.ToString();
              string parameterValue = "";
              bool isParameterVisible = reportParameter.Visible;
              paramList.Add(new ReportParameter(parameterName, parameterValue, isParameterVisible));
         }

         rvReportViewerControl.ServerReport.SetParameters(paramList);
    }

    rvReportViewerControl.RefreshReport();

This site has a lot of useful information.



来源:https://stackoverflow.com/questions/1632358/reports-using-microsoft-viewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!