BACKGROUND
- I'm writing a method that will (eventually) take as input a System.Data.DataTable and render it as an (simple,tabular) SSRS report into a Winform using the Microsoft's ReportViewer Control (http://www.gotreportviewer.com/)
- In order to do this I need to (1) dynamically create an RDL file based on the DataTable (2) load the RDL into the ReportViewerControl (3) bind the ReportViewerControl to that DataTable
QUESTIONS
- Ideally I would simply love a link to a sample that did all of the above - I have searched but have been unable to find one.
- Otherwise, I need some help specifically with #1 and #3 above.
- For #1 - Is there a simple way of generating an RDL file dynamically at runtime? (I have already starting writing code to emit the correct XML, but re-using something will same me some time)
- For #3 - It's unclear to me how to bind the ReportViewerControl to a DataTable I have locally. Most of the examples I found assume I that ReportViewer control will fetch data that is on a remote SQL server (which is to be expected) instead of getting it from a local DataTable.
CONTEXT
- I'm only recently starting working with the ReportViewer control - I have found samples googling - but none seem to cover the full scenario
- I do not know the schema of the DataTable ahead of time. The DataTable's schema will not even be constant during calls to my method which will render it.
- I cannot use a different reporting control - I must use the ReportViewer control. If you do know of other reporting controls that make this task easy, please do let me know. Even if it doesn't solve my current problem, it's useful for later.
- The person viewing this report is an end-user and does not have any rights to publish RDL to a SSRS server
- The DataTable will already be sorted, filtered, etc. The types will all be simply values of strings, ints, doubles, and dates. The DataTable will be of reasonable size - 1-30 columns and have from 100 to 5000 rows. The DataTable is also being constructed locally (sometimes manually constructed via code) and is not retrieving data from some remote datasource.
- The data will always be rendered as a simple table (no charts, etc.). Later on I may need to add grouping
- I cannot switch to using HTML, XAML, etc to display the report - there are features in ReportViewer that I will eventually make use of that that HTML, XAML, etc do not have.
UPDATE ON 2010/01/15
Starting from Jon's answer below I was able to achieve what I needed. As he mentions the difficut part is learning the RDL XML schema and knowing what RDL elements to write to achieve the desired kind of report.