We are using Crystal Reports XI R3 for our reporting purposes. We have created typed dataset which act as the datasource for the reports.
I am facing an issue including a bar chart along with the grid on one of the reports. The chart gets embedded into the header section by default and the grid is generated out of the details section.
If I design the report without the chart, it all works fine. If I supply 8 rows of data, it publishes 8 rows in the report too. But if I include a chart on the same report, the data in the details section gets multiplied, and I get 64 rows or something with the same datasource.
This should be a pretty straight forward functionality, but it doesn't seem to be working for me. I tried include a sub-report and have the details section in the sub-report and it works fine. But, I can't go with this approach either as this report in itself would be included to another as a sub-report and we cant have nested sub-reports in Crystal.
Please help me with some pointers on what could be going wrong ?
Edit: On further investigation, it looks like a problem with having two different tables to populate the chart and the grid. If I use a single table for both, it works fine.
Attaching screenshot on #Kalyan's request:
The issue indeed was with using multiple unrelated tables for a single report. Crystal Reports by default doesn't allow using multiple tables, unless they are linked in someway. If you dont specify a link, it tries to apply a link on its own and runs a join while publishing the report.
Due to this join, the data was getting repeated for me.
To resolve the issue, I created a group on the primary key of the table corresponding to the grid, and used the group to generate the grid and suppressed the details section. Problem resolved.
Related
I have little to no experience in using Datasets and Crystal Reports so please don't bash me if the answer is really obvious, I didn't manage to find the answer on-line.
I have a C# Winforms application, containing a Crystal Report that takes its data from a DataSet. I populate the DataSet dynamically from inside the application.
In the past, if I added another column to the DataSet, I could right click the DataSet in the Crystal Report and click "Verify Database" to make the new columns available in the Report.
Now, if I do this the following window pops up:
There is no item available in the Class Name combobox, and if I check the checkbox, another combobox appears which is also empty.
Please note that I populate the DataSet from inside the program, so there is no connection.
How can I update the DataSet in the Crystal Reports, so that the new columns become available?
Thank you.
P.S.: I have tried the following solution but it didn't work: Update DataSet Schema On Crystal Reports for VS2008 because I am presented with the same window as above.
Also, this is what I see, might be useful:
Edit1: The fields appear in the Data Sources but do not appear in the Field Explorer.
I already have some Formula Fields that have the same name as the newly added Columns but removing them didn't help either.
I finally managed to solve it by myself. There are three things I did and I'm not quite sure which one did the trick since I can't seem to manage to recreate the problem.
I renamed the Formula Fields that had the same name as the DataTable columns I added.
I clicked the " ... " box and reselected the same file.
I added the Internal Connection ID {294de39c-3e3c-4748-9138-53d4be2a74a6} in the Class Name textbox.
The first two probably didn't help since they didn't work before. It did work when I added the string so that's probably the solution, but this didn't work the first time either.
Hopefully my wasted hours would save someone's time.
This is my solution. Here is the steps:
Create New DataSet and drag the table from SQL Server ObjectExplorer
Right click on Database Fields
Choose Datasource Location
Click on the table on new DataSet created on step 1
Click Update
Hope it can help
Using Crystal Reports and .NET I have a requeriment where I need to print 2 copies of the same report on each sheet. I´m able to do this using two subreports setting CanGrow to false, but this doesnt work cause my report may have more than one page, and CanGrow will just crop the rest of the report. Setting CanGrow to false will cause the two reports to overlap, or print one after another. I also tried making a double report, Header - details - footer, and Header - details - footer again (repeating the same information), but crystal reports doesnt allow me to have multiple details sections(with header footer sections between them).
I´m able to reproduce what I want using MsWord, in the printing settings changing the printer setting "print multiple copies" to 2, and then typing and setting Page range to "Page: 1,1,2,2,3,3,4,4... " but the printing API from Crystal Reports won´t let me adjust these settings, not even printing APIs from .NET, so I though of using Native Win32 API, but even if I´m able to do this with Win32 I don´t know how to tell Crystal Reports to use my printing functions.
I´m pretty new to crystal reports so maybe there is a simple solution for this. If someone can help.
I think you'll need to keep your subreport the way you have it, with the report details you want copied, but you can't place the two instances of the subreport in the same section and expect them to space themselves correctly. You'll need to use a second detail section in your main report for your second subreport, then they shouldn't overwrite each other. The detail sections both need cangrow = true set.
OK, all you should need is 2 reports, one formatted the way the customer wants (headers, footers, etc.) to use as the subreport, and one without any headers or footers, but 2 detail sections with cangrow=true and an instance of the subreport in each detail section. I'm not sure why you want a new page after 5 records, but try taking that out and see if you can print the same subreport twice within a main report.
I think I kind of solved it. I created two reports: Orignal, and Copy, and supressed all sections except details section and added a group using the workaround mentioned here:
http://www.c-sharpcorner.com/UploadFile/mahesh/SubReportPH10062006160749PM/SubReportPH.aspx
to be able to use headers that would repeat on every page.
I put all my header information on the group header, and the report footer information on the group footer(other sections can´t be used since they wont respect the spacing I need, that´s the major drawback of this workaround), and limit the details section to a number of records that will fill only half of the page. In the copy version I added a space in the header equal to half of the page. Then I created the report that will hold both subreports with all sections supressed and only one detail section, and added both subreports there one on top of another. This will print the second subreport at the bottom of the page leaving the space from its header for the first subreport to print on top, I still don´t know how to repeat footing section on every page by now but I think I don´t need it.
I need to add a second DataTable from our app's main DataSet into a report, but not having much luck.
We have several simple local reports in RDLC files, each with a single DataTable based on a view in our application DB. I need to improve one of the reports to add information from another table. This other table is defined in the same core DataSet which we use for reports in our .NET 2.0 WinForms application. Since the two tables are in the same DataSet, can I just make sure that both tables are loaded into the DataSet and then point the report at the DataSet instead of the DataTable? Something else?
Needless to say, I've been playing around with this for a while and not getting anywhere.
TIA,
Matt
OK, I got this working and, in retrospect, it was pretty easy. I just didn't know which menus to use for getting VS to hook everything up, and which order to do them in.
Looking at the Designer.cs for my form was actually the most helpful thing I did. I noticed was that the ReportViewer has a default BindingSource pointed at the first table. Originally, I was hung up on trying to give the BindingSource a DataSet instead of a DataTable, but then I decided to try making a second BindingSource instead.
Maybe there's a better way, but here's basically what I ended up doing:
With the RDLC in the designer, clicked the Report menu then Data Sources.
On the Report Data Sources dialog, chose the additional DataTable from the drop-down and clicked Add to Report. (I also renamed the new data source to just be the name of the additional data table; VS had created some gigantic long name based on the full namesspace.) OK to close the dialog.
On the designer for the form that contains my ReportViewer control, clicked the ReportViewer's smart tag (the little arrow in the top right corner of the control) and then selected Rebind Data Sources. This made a second BindingSource appear at the bottom of the Designer surface.
Clicked the ReportViewer's smart tag again and this time chose "Choose Data Sources" to confirm that the ReportViewer now had two data sources, each bound to one of BindingSource instances now on the form.
Revised the my form's OnLoad code to load rows into the second DataTable.
Went back to the RDLC file, added a new table and set the detail cells to fields in the second DataTable -- and it worked!
Hopefully this will save someone else a couple hours someday.
Figured out a way to use it in Visual Studio 2010.
Click on View > ReportData and when the report data is seen , click on Datasources and then click on add. DO this as many times as the number of datasets needed.
Now in the smart tags of the reportviewer, click on choose datasources, this will show each of the datasets. To associate the datasets with a binding source, you will have to click on Project and then further click till you get the appropriate class, this will cause the binding sources to be created.
This work around is very useful if you have multiple tablixes and you have to associate a binding source to them within the same report when the report is displayed on the report viewer
I'm trying to summarize data in a crystal report. I'd like to create a columnar view of data in crystal but am not sure how to do it. I was wanting to use a crosstab but when I try to insert, the control never appears. I create a crosstab report but when done, it comes to a blank report. I want it to be like this except columns would be vehicleCategory and rows would be individual charges
1 - Any idea what I'm doing wrong and
2 - is there a better way to do this?
Thanks!
Ok, I'm going for the Necromancer badge again. :)
You should be able to open the Cross-Tab expert, and put vehicleCategory as the columns, individual rows would be the individual charges and the summarized fields would be what ever you want to sum for (ie. Count of vehicleCategory). On the custom style tab make sure that you aren't suppressing the grand totals until you make sure that you are showing data. Also make sure that you are suppressing or hiding the section that you are putting the cross tab in.
I'm sure you are well past this issue now, but I figured I'd throw an answer out there for you so that if nothing else I can try for a new badge. :)
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.