How to create a report without data.
How to create a report without data.
I would like to create a report template based on a data set's schema so that I may define the report in the designer. But I want to bind it to a dataset at run time for the data to be used to fill the report. Essentially, the columns returned are always the same, however, the criteria used to generate the report is always different. Is this something that is possible?
How to create a report without data.
Yes this is possible.
If you want to create a report template based on the structure of a dataset you can register the dataset with the report and enter design mode. This will convert your dataset to a Datasource in the report and you can then work on the datasource to design your report template.
When you want to use the template to present your data, you can load the report template you designed from a file (or other sources), register your dataset that contains the data and preview the report.
Also have a look here for some video demonstrations
http://www.stimulsoft.com/ReportsNetVideos.aspx
And there is also a Demo application and some projects that come installed when you install StimulReports.Net. You can find them in your start menu under programs -> stimulsoft or in the stimulsoft installation folder.
If you want to create a report template based on the structure of a dataset you can register the dataset with the report and enter design mode. This will convert your dataset to a Datasource in the report and you can then work on the datasource to design your report template.
Code: Select all
StiReport report = new StiReport();
report.RegData(myDataSet);
report.Design();
Code: Select all
StiReport report = new StiReport();
report.Load(@"c:\myReports\reportTemplate.mrt");
report.RegData(myDataSet);
report.Show();
Also have a look here for some video demonstrations
http://www.stimulsoft.com/ReportsNetVideos.aspx
And there is also a Demo application and some projects that come installed when you install StimulReports.Net. You can find them in your start menu under programs -> stimulsoft or in the stimulsoft installation folder.
How to create a report without data.
This is almost verbatim what I am currently doing. The only difference I can see is that I am using the WebViewer to render the report.
So I am using the following code in the Page Load event in demo project to try to render the report.
When I omit the creation of a dataset
I get all my records back and the report renders with about 550 pages.
The dataset in my test is filled using the exact same query except that it returns only the top ten results.
When rendering the report with RegData(resultsSet) call I get the stiWebViewer, but I do not see my report template content (header, footer, etc.), nor do I see any of the data in the dataset. What might I be missing?
So I am using the following code in the Page Load event in demo project to try to render the report.
Code: Select all
DataSet resultSet = new DataSet();
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(sqlString, conn);
SqlDataAdapter adapter = new SqlDataAdapter(command);
adapter.Fill(resultSet);
conn.Close();
}
StiReport report = new StiReport();
report.Load(templatePath + "CRTest_Template.mrt");
report.RegData(resultSet);
StiWebViewer1.Report = report;
Code: Select all
StiReport report = new StiReport();
report.Load(templatePath + "CRTest_Template.mrt");
StiWebViewer1.Report = report;
The dataset in my test is filled using the exact same query except that it returns only the top ten results.
When rendering the report with RegData(resultsSet) call I get the stiWebViewer, but I do not see my report template content (header, footer, etc.), nor do I see any of the data in the dataset. What might I be missing?
How to create a report without data.
I think I have figured out the missing puzzle piece.
DataSources are named, so:
only gets us part of the way there, we have to explicitly name out datasource.
then when we are viewing the report, we have to not only RegData our new dataset, but we have to do so by name, so that the existing datasource is overridden.
Doing this I have been able to successfully execute my proof of concept project. If my understanding of how this works is not accurate I would appreciate any necessary corrections. I want to understand this process as much as possible, and not just develop a cargo cult code base.
DataSources are named, so:
Code: Select all
StiReport report = new StiReport();
report.RegData(myDataSet);
report.Design();
Code: Select all
StiReport report = new StiReport();
report.RegData("MyDataSource", myDataSet);
report.Design();
Code: Select all
DataSet resultSet = new DataSet();
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(sqlString, conn);
SqlDataAdapter adapter = new SqlDataAdapter(command);
adapter.Fill(resultSet);
conn.Close();
}
StiReport report = new StiReport();
report.Load(templatePath + "CRTest_Template.mrt");
report.RegData("MyDataSource", resultSet);
StiWebViewer1.Report = report;
How to create a report without data.
Hi
Yes, you are right. RegData registers data in the report Dictionary according with the name of the Connection.
Thank you.
Yes, you are right. RegData registers data in the report Dictionary according with the name of the Connection.
Thank you.