Crystal Report output PDF file in C #

Source: Internet
Author: User

The following Crystal Report class libraries are introduced into the project
Crystaldecisions.crystalreports.engine
Crystaldecisions.reportsource
Crystaldecisions.shared
Crystaldecisions.web


Add the Crystalreportviewer control to the page. Add code for his initialization at the same time
System.Data.DataTable dt = ....//The method by which the data table is written. Can write according to their own hobbies, but must get
DataTable
CrystalReport1 cr = new CrystalReport1 ();//The CrystalReport1 here is the file name that you set up the report is the RPT name.
Cr. Setdatasource (DT);
This. Crystalreportviewer1.reportsource = CR;


If you want to export the file, the code is as follows
private void Button1_Click (object sender, System.EventArgs e)
{
System.Data.DataTable dt = ....;
CrystalReport1 cr = new CrystalReport1 ();
Cr. Setdatasource (DT);
Cr. Exporttodisk (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "c:\\output.pdf");
Cr. Close ();
}
Where CrystalDecisions.Shared.ExportFormatType.PortableDocFormat can control the type of output file

Crystal Report output PDF file in C #

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.