conditional loading of subreports in a Microsoft ReportViewer - c#

I have a set of about 15 local reports that show up in a user properly designed user control. However, for the purposes of emailing / saving / printing we have included respective RDLCs with static content and datasets and parameters to control the dynamic data.
There is a Consolidated report that is generated and this is not displayed anywhere but just exported. The ReportViewer component for this report has a ConsolidatedReport.rdlc file that references different SubReports. Everything works fine here till we had a request to generate reports in Spanish.
So to display reports in Spanish, we made code changes and for the static content we included another set of 15 RDLCs each corresponding to its English version. These changes worked seamlessly as well.
However, these things fail miserably when it comes to exporting the ConsolidatedReport.rdlc which shows up the English content only irrespective of the language chosen by the user. I have handled the SubReportProcessing Event to correctly get into the subreports loading.
However, I do not know how shall we force the subreports section to load the Spanish language .rdlc file instead of the default English language. I have also looked at the DrillThrough event option as well, but I am not able to find out a way to trigger it and also appropriate sequence to handle it. I have also looked into the (LocalReport)e.Report.LoadSubReportDefinition(...) call as well. Need some help working this out.
Thanks,
Bhushan.

Related

What kind of pagination crystal report uses?

Here we are talking about inbuilt pagging of crystal report.
which type of pagination will be in action when i click on previous or next button on report viewer??
1) load only that much data that is need to be shown?
or
2) load all the data and show only what is need to be shown?
CR loads all data for main report first. Then, while rendering, it loads all subreports data, required up to current page display. For pagination this means that next page navigation may query data for subreports, previous page uses cached data always. CR actually needs to render all pages up to current to know, where to place page breaks.
This is empirical evidence only - it could be possible that for some kind of reports or environments CR starts rendering before all data is read, but I haven't seen that yet :) Our reports usually include some nasty grouping and similar, which for example requires all data already present in report header or every page footer (pages count, totals etc). We are using "desktop" version of CR engine+viewer, maybe web server engine behaves differently.
Crystal Report builds the whole document, you can see it in the page numbering. Another technical reason, that CR can use forward only cursors that makes back paging impossible, it must load the data into the memory.

How can I generate a report in WPF?

I'd like to know of any tools to generate a report in wpf.
What I want to do is to generate the report and export it immediately to a pdf, csv or just print it. I don't want the client to be able to "adjust" the report from within my application. Also the report tool should give me lots of freedom, since I'm geerating reports from a datagrid that is constantly changing, according to the user's commands (in other words .. it's dynamic)
Does anyone know of any tools that allow me to do that (preferably an open source tool, but I'm not tied to it being open source)?
Reporting isn't specific to WPF. You can look at Crystal Reports, SSRS Reports (both server *.rdl and client embedded *.rdlc), or tools from companies like DevExpress' XtraReports.
The +1 for using SSRS Reports is that there appears to be a Mono project that will allow you to render them, so you're not tied 100% to the Microsoft server stack, if you have that requirement. Look at FYI Reporting from the provided link.
If you are familiar with crystal reports, this may be useful to you. Otherwise you could always use xslt and xml
This answer makes a a compelling arguement for micrsoft or third party reporting compared to xslt "hand made" reports.
Edit: As a first go, it may be adviseable to use the crystal report creation wizard
You can use Crystal Reports, just like we use it in WinForms.
You have several options here.
You can print a visual to pdf using a virtual printer: http://www.pdfforge.org/products/pdfcreator.
There are also XPS to PDF converters.
And, of course, there are numerous WPF based report generators.
You're question is quite clear, so I wasn't sure what exactly you were after.
You may consider using ActiveReports to fulfill your reporting needs as ActiveReports has a viewer and end user report designer control which can work quite well in WPF environment.The End user designer control will also allow your end users modify reports at their will.
Regarding the exporting capabilities , ActiveReports will let you export to PDF,Excel,Word,Tiff,Jpeg,Text etc.And lastly activereport will give you the flexibility you are looking for as it can be bound to datasets,XML,OLedbm,sql,Excel sheets, text,array, objects etc ..
You can visit these links to know more how ActiveReports works on WPF:
http://blogs.gcpowertools.co.in/2011/11/how-to-view-report-created-using-active.html
http://blogs.gcpowertools.co.in/2011/08/how-to-host-active-reports-end-user.html

Good web reports designer

I faced wuth task of creating system that will generate various medical papers for patients based on DB data. There is a lot of 3d party companies that will use this product therefore this product will be web-based. The main purpose of this product is printing this papers I have described above. Users already has prepared paper blank on which personal information will be imprinted. All users has various printers and the main issue I need to solve is that every printer prints in own maner and imprinted characters losts their positions.
The possible way I can solve this is to provide reports designer embedded in system, that allow every user "adjust" report to get printer prints properly.
By the way, we has all necessary documents reports storing in .fr3 files. It's 'cause we use same reports in another desktop application and we use fast report engine in that application. So the only one web reports designer I have found is Stimul soft reports web designer. But it's big, awkward and seems too heavy for this small project. Could you guys advice me some lightweight web reports designer/engine that can solve my issue?
P.S.: sorry for my English. I will use ASP .NET MVC3 (C#) for implementing this project.
The key question is do you need report design via the browser, do you merely need printer positioning, or can the report design be performed on the user's computer and it's just report generation that must be on the browser.
If you need report design in the browser then you are limited to products like Stimulsoft which as you said tend to be ackward and limited.
What you may be facing, based on your question, is that you need to position the report on the printer as all printers set the upper left of the generated report in a slightly different place on the paper. The best way to handle this issue is to make your report work fine regardless of the upper left of the printing on the page as the differences are small. But if that won't work, just prompt the user for the adjustment values.
Finally, if you want a system where it is very easy for non programmers to design reports, and the designer can be on their computer, please take a look at Windward Reports (disclaimer - I'm the CTO at Windward. With Windward you design your reports in Microsoft Word, Excel, or PowerPoint so it is both very easy and very powerful.
I does not understand what your problem is with position. A normal reporting solution print identical on different printers (not valid for old 9 dot printer).
Do you want print in a form (blank)? i-net Clear Reports has a page option for form print and an Online Designer. You find the form print option in the page setup dialog. If you enable the form print option the left and right margin will not change and the print will not scale.
Or do you search a simple designer in a browser? Then you can take a look in the ad-hoc reporting.
Use SQL-Server reporting services (2008 R2 in it's latest and most bug-corrected version).
It can render to HTML, and export to PDF, XLS, CSV and to Word (Word only with a commercial custom extension).
It also has a COM-object, which allows the report to run standalone, without SSRS installed.
SSRS also supports OracleProvider, apart from SQL server.
If a MS-SQL dependency is an overkill, you could take a look at Eclipse BIRT, which is a Java SSRS clone, which has a web viewer and JDBC database connectivity (however, the report format is not compatible).
The bad thing about it is, that it requires the version of Visual Studio that came with the SQL server version (so no designing of SSRS 2008 R1/R2 reports in Visual Studio 2010, you need Visual Studio 2008).
take a look into List & Label. It has a Webserveredition for generating output on web-applications and if you need to modify them there is an ActiveX available. We've done some successful projects with this stuff. Just try it out!
Take a look at Izenda AdHoc
.
In-browser Designer, In-browser Viewes, highly customizable but very simple API, exports feature, multiple databases types support.
You could even change reports looking using CSS styles.
Of course, compatible with MVC.

How To Speed Up Loading DataSets

When Using SQL Server Reporting Services (client Reports), whenever a Client (rdlc) report Opens Visual Studio Loads entire application datasets,
how to speedup loading this all datasets or how to change the process to only load specific Dataset to use in Report ?
Bulk Insert (or the bcp utility) is your Friend for speedy data imports. Your probably going to have to write a data loader in some language though.
database snapshot could be an option
http://www.sql-server-performance.com/articles/dba/sql_server_database_snapshot_p1.aspx
I may be understanding you question wrong, but on Win Forms I've been loading the needed data sets manually. I basically have a method that loads the proper data from my database, attach the needed data sets to my report viewer using Me.ReportViewer1.LocalReport.DataSources.Add, then I just display my report using Me.ReportViewer1.LocalReport.ReportEmbeddedResource. My reports are embedded resources, but you can load it from a file too, I just can't remember off the top of my head. Once everything is loaded, call RefreshReport, and the report displays. Well, those are the main points, I don't have my code to look, but I know those are the basic steps.
Currently I have been researching how to load data sets on the fly as the user navigates through the report. My work around for this at the moment is to capture the ReportError event, check what report is trying to be displayed from the sender (this is the report viewer object), and load the dataset using the above. The only issue that I am having is that I don't have a loading screen when I am loading the dataset at this point, so it looks like my application freezes. I haven't figured out how to get back to that circular loading screen, but for now, I have a loading window that is displayed while I load. remember, when you get the error, the report trying to be displayed is already set as the local repot, so all you have to do is have a case/if statment checking for the report and loading the data as needed.
Can't you set a default parameter to something which stops much being returned, and only change it to a real one at run-time?

Using Crystal Reports in Visual Studio 2005 (C# .NET Windows App)

I need to create reports in a C# .NET Windows app. I've got an SQL Server 2005 database, Visual Studio 2005 and am quite OK with creating stored procedures and datasets.
Can someone please point me in the right direction for creating reports? I just can't seem work it out. Some examples would be a good start, or a simple How-to tutorial... anything really that is a bit better explained than the MSDN docs.
I'm using the CrystalDecisions.Windows.Forms.CrystalReportViewer control to display the reports, I presume this is correct.
If I'm about to embark on a long and complex journey, what's the simplest way to create and display reports that can also be printed?
I have managed to make this work now.
Brief Overview
It works by having a 'data class' which is just a regular C# class containing variables and no code. This is then instantiated and filled with data and then placed inside an ArrayList. The ArrayList is bound to the report viewer, along with the name of the report to load. In the report designer '.Net Objects' are used, rather than communicating with the database.
Explanation
I created a class to hold the data for my report. This class is manually filled by me by manually retrieving data from the database. How you do this doesn't matter, but here's an example:
DataSet ds = GeneratePickingNoteDataSet(id);
foreach (DataRow row in ds.Tables[0].Rows) {
CPickingNoteData pickingNoteData = new CPickingNoteData();
pickingNoteData.delivery_date = (DateTime)row["delivery_date"];
pickingNoteData.cust_po = (int)row["CustomerPONumber"];
pickingNoteData.address = row["CustomerAddress"].ToString();
// ... and so on ...
rptData.Add(pickingNoteData);
}
The class is then put inside an ArrayList. Each element in the arraylist corresponds to one 'row' in the finished report.
The first element in the list can also hold the report header data, and the last element in the list can hold the report footer data. And because this is an ArrayList, normal Array access can be used to get at them:
((CPickingNoteData)rptData[0]).header_date = DateTime.Now;
((CPickingNoteData)rptData[rptData.Count-1]).footer_serial = GenerateSerialNumber();
Once you have an arraylist full of data, bind it to your report viewer like this, where 'rptData' is of type 'ArrayList'
ReportDocument reportDoc = new ReportDocument();
reportDoc.Load(reportPath);
reportDoc.SetDataSource(rptData);
crystalReportViewer.ReportSource = reportDoc;
Now you will need to bind your data class to the report itself. You do this inside the designer:
Open the Field Explorer tab (which might be under the 'View' menu), and right-click "Database Fields"
Click on 'Project Data'
Click on '.NET Objects'
Scroll down the list to find your
data class (if it isn't there,
compile your application)
Press '>>' and then OK
You can now drag the class members
onto the report and arrange them as
you want.
Crystal is one possible option for creating reports. It has been around a long time and a lot of people seem to like it.
You might want to take a look at SQL reporting services. I have used both but my preferance is SQL reporting services. Its pretty well integrated into studio and works similar to the other microsoft projects. Its also free with the sql express etc.
This is a good article on beginning reporting services:
http://www.simple-talk.com/sql/learn-sql-server/beginning-sql-server-2005-reporting-services-part-1/
You can use the report viewer with client side reporting built into vs.net (ReportBuilder/ReportViewer control). You can create reports the same way as you do for sql reporting services, except you dont need sql server(nor asp.net). Plus you have complete control over them(how you present, how you collect data, what layer they are generated in, what you do with them after generating, such as mailing them, sending to ftp, etc). You can also export as PDF and excel.
And in your case building up a report from data and user input, this may work great as you can build up your own datasource and data as you go along. Once your data is ready to be reported on, bind it to your report.
The reports can easily be built in Visual Studio 2005 (Add a report to your project), and be shown in a Winforms app using the ReportViewer control.
Here is a great book i recommend to everyone to look at if interested in client side reports. It gives a lot of great info and many different scenarios and ways to use client side reporting.
http://www.apress.com/book/view/9781590598542
I second alex's recommendation to look at sql reporting services - if you have a sql developer license, then you probably already have reporting services
i don't like crystal reports, too much tedium in the designer (editing expressions all the time) too many server-deployment issues (check those license files!)
I use Crystal. I will outline my method briefly, but be aware that I'm a one man shop and it may not translate to your environment.
First, create a form with a CR Viewer. Then:
1) Figure out what data you need, and create a view that retrieves the desired columns.
2) Create a new Crystal report using the wizard giving your view as the source of the data.
3) Drag, drop, insert, delete, and whatever to rough your report into shape. Yes, it's tedious.
4) Create the necessary button click or whatever, and create the function in which to generate the report.
5) Retrieve the data to a DataTable (probably in a DataSet). You do not have to use the view.
6) Create the report object. Set the DataTable to be the DataSource. Assign the report object to the CR Viewer. This is one part for which there are examples.
Comments:
If you lose the window with the database fields, etc (Field Explorer), go to View/Document Outline. (It's my fantasy to have Bill Gates on a stage and ask him to find it.)
The reason for setting up the view is that if you want to add a column, you revise the view, and the Field Explorer will update automatically. I've had all sorts of trouble doing it other ways. This method also is a work-around for a bug that requires scanning through all the tables resetting which table they point to. You want to hand Crystal a single table. You do not want to try to get Crystal to join tables, etc. I don't say it doesn't work; I say it's harder.
There is (or was) documentation for the VS implementation of Crystal on the Business Objects web site, but I believe that it has disappeared behind a register/login screen. (I could stand more info on that myself.)
I've had trouble getting Crystal to page break when I want, and not page break when I don't want, etc. It's far from the best report writer I've ever used and I do not understand why it seems to have put so many others out of business. In addition, their licensing policies are very difficult to deal with in a small, fluid organization.
Edited to add example:
AcctStatement oRpt = new AcctStatement() ;
oRpt.Database.Tables[0].SetDataSource(dsRpt.Tables[0]);
oRpt.SetParameterValue("plan_title",sPlanName) ;
crViewer.ReportSource = oRpt ;
I found the following websites solved my problems. Included here for future reference.
CrystalReportViewer Object Model Tutorials for the tutorial on how to make the whole thing work. And also Setting up a project to use Crystal Reports
and specifically preparing the form and adding the control
i think this may help you out
http://infynet.wordpress.com/2010/10/06/crystal-report-in-c/
I strongly recommend trying an alternative reporting solution - I have a lot of experience with Crystal, and have managed to do some funky things with it in .Net, but quite honestly the integration of Crystal and .Net is an absolute pig for anything but the simplest cases.
I have tried RS. I am converting from RS back to Crystal. RS is just too heavy and slow (or something). There is no reason to have to wait 30 seconds for a report to render is RS when Crystal does it in under a second.

Categories

Resources