I have written a winform program that gathers information from several database tables and displays this information in a datagridview. The user likes it a lot, but they've requested an additional feature: the ability to print the information in the datagridview to their printer.
All of the data that the user wants to print is in the datagridview. If you had to make this kind of change to this program, what method would you use to get the information to the printer?
codeproject's got a bunch:
The DataGridViewPrinter Class
Printing of DataGridView
Another DataGridView Printer
Printing a DataGridView on DotNet Framework
DataGridView Print/Print Preview Solution - Part I
DataGridView Print/Print Preview Solution - Part II
Plus more. I haven't tried any of these myself though.
One way of doing that nicely, if you are able to, is create/design a local report (.rdlc) and print that report without showing the ReportViewer control. An example of that is here.
Related
I am working on a C# WinForm application that currently has several RDLC reports in it, and those reports need to print at a given time without any user interaction.
The good news, is I found code to do that at Printing A Local Report Without Preview
Unfortunately, while that works fairly well, when it prints, it puts up a small window saying "Printing page x of y" - is there any way to hide/suppress that window, so it can print silently while the user continues to work within the application?
Never mind - I found the solution on my own:
Turns out all you need to do is add the following line before doing the printDoc.Print in the code:
printDoc.PrintController = new StandardPrintController();
Because you are using PrintDocument you can use this solution:
How to skip the dialog of printing in printDocument.print() and print page directly?
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
Ok I am not sure the question I need to ask so I am going to describe what I would like to be able to do I am wondering if this is possible.
I have some paper forms that I am creating webpages for so that the information can be stored in the database using a computer. I have already created one and the user enters the information it is stored in the database then the user has the option to print a crystal report that looks like the paper form with the information entered.
Is it possible to cut out the middle man and have a crystal report as a webpage that the user can hit enter the information into the report and then hit a save control on the page to save it to the database and print from there.
If I am not asking the right question or you need more information please feel free to ask. If it is possible to design the report and then use that on the page make it editable to the client then that would make my life a whole lot easier I just dont know what to look up.
If what you need is to let user fill out a form and the data can save to database, and then the user can access the form, then there are several options:
Use Adobe forms. In this way, you can create pdf forms and you can let people download or email the forms. The forms are fillable, and when they submit the form, all you need is handle it(in forms of xml) at your server side to save it to your database. You could pre-populate data so that when the user download the file and open it, it has some data filled out. The tool you will need to create Adobe forms is Adobe LiveCycle and you have to learn how to use it. Our company use it for some of our web forms because they are secure and can be emailed. Of course you will need to implement server side code to handle it.
Use asp.net web form. You create web form and linked to database. You handle the form data user entered and save them to the database by using ado.net. That give you the most flexibilities.
If you want user open the form they entered in a specific format so that it will looks like a "form", you have two options:
<1> Pass your raw data to a specific css to let user print out in a nicer format instead of just plain text or even the web page. Again, you get flexibilities through this way.
<2> Use SQL Server Report Services(If you use sql server). In this way, you can create print layouts by using visual studio, and then write a stored procedure to get data. If you do this way, the user will also get a pdf file. They can save it or print it.
Hope this helps.
It is possible (assuming you are using a version of SQL which allows you to write stored procedures), but it's a very bad idea:
Write a SQL stored procedure, with a parameter for each field to be entered, that updates the relevant database tables with the appropriate parameter values.
Generate a Crystal report from the stored procedure.
Note that the only functionality available to the data entry fields (lookups, validation, etc.) will be that available to Crystal Report parameters in whichever version of Crystal you are using - generally, this functionailty is minimal.
I've inherited a project that uses Active Reports. I'm required to basically create a simple pdf that holds data that's in a DataGrid on one of my ASP.NET pages.
I've only found a single walkthrough on the DataDynamics website and it only applies to users of VS2003 and VS2005.
The report I need doesn't need to be interactive. I don't need to use Document and Page events. I just need to take what I have in a DataTable (which is bound to my grid) and create a pdf file, which will be available for download.
Is there a straightforward way to create this simple, static report with ActiveReports? Thanks.
kmarks,
You can indeed do this very easily, you can use the same DataTable as a datasource for report by setting the datasource property of the report to the DataTable.Then you just need to add an ActiveReports TextBox control to the Details section of the report and then set its DataField property to a column name in the datatable to bind a field from the datatable to the TextBox control.You can do this either at design time or in the code behind
After you have done this,just create an instance of the report,call the Run the method on this instance and then export the report document to PDF.
I would also suggest you to go through the following link which can help you achieve the same.
http://www.datadynamics.com/Help/ActiveReports6/arWLKCustomWebExporting.html
You can also download a sample application which converts a DataGrid to PDF report using Active Reports form here
ftp://ftp.fpoint.com/ActiveReports/Samples/GridToPdf.zip
Regards,
Abhishek Dutta
Grapecity
I have a C#.NET Winform Application, using which, printing of bills etc. would be done.
But the printing would be done by users using a DMP printer.
So is it possible to send the print to a DMP printer in winform application. If yes, then how?
Also, i have a DataGridView in a Form. Now I want to Print that table which is displayed in the gridview. How do i do this? Will I have to use Crystal Reports or else?
Well not sure this answers you well but i would use PDF Sharp or Migra doc to genereate pdf file from your data and print from there, this way i would not have to do Printer DMP settings (I guess)
The easiest and quickest solution is to use the Visual Basic PowerPack's PrintForm control (You can use it in C# projects as well).
http://msdn.microsoft.com/en-us/vbasic/bb735936.aspx
Just drag the control on to your form then from code call
printForm1.Print();
This will print whatever is on the form, so just design your report on a form then call that code, and you're done.
look at Print the form (Visual C #) you can also use VB power Pack
u can only do code like in C# to print any document or page.
PrintDialog p1= new PrintDialog ()
p1.ShowDialog();
I would use visual studio's emmbeded control calles "ReportViewer" control.
You can find it under "Reporting" section in the toolbox .
Please note that you need to have an app that target's framwork 3 and above for you to see this control.
In this control you can Print to selected printer , export to pdf,word and excel.
Check it out.
I do know there's already an accepted answer but I wish to add a new link to a youtube tutorial that i found recently. Print receipt
Cheers.