Export data to an Excel file from an RDL file by LocalReport

Source: Internet
Author: User

protected void Sssss_click (object sender, EventArgs e)
{
LocalReport report = new LocalReport ();
Report. Reportpath = @ "D:\PDFTEST.RDL";

DbProviderFactory dbf = Dbproviderfactories.getfactory ();
using (idbconnection con = dbf. CreateConnection ())
{
string sSQL;
sSQL = "Select Sponsor_title, Group_pdf_code, Provider_network, Effective_date, Build_type, Group_begin_date, REDLINE_ Posted_date, sponsor_title_changed, New_renewal_form, Pharmacy_complete, Administration_complete, ELIGIBILITY_ Finace_complete "+
", Healthx_complete, Cert_complete, Cert_audit_complete, Post_for_networks_date, redline_posted, COMPARE_PLAN_FORM, Assign_benefit_build_specialist, Begin_benefit_build, Compared_reviewed_plan, model_plan_copied, SELF_BENEFIT_ Audit_complete, assign_peer_review_specialist "+
", Peer_review_complete, Begin_cliams_auditing, Cliams_audit_complete, REMOVE_SPONSOR_FROM_WATHC, ESTIMATED_TOTAL_ Days, Original_est_cmplt_date, Healthx, Std_group_begin_date, Std_redline_posted_date, std_sponsor_title_changed, Std_new_renewal_form, Std_pharmacy_complete, Std_administration_complete, std_eligibility_finace_complete "+
", Std_healthx_complete, Std_cert_complete, Std_cert_audit_complete, Std_post_for_networks_date, STD_REDLINE_POSTED , Std_compare_plan_form, Std_assign_benefit_build_specialist, Std_begin_benefit_build, STD_COMPARED_REVIEWED_PLAN, Std_model_plan_copied, Std_self_benefit_audit_complete, Std_assign_peer_review_specialist, STD_PEER_REVIEW_ Complete, std_begin_cliams_auditing, Std_cliams_audit_complete, STD_REMOVE_SPONSOR_FROM_WATHC, STD_ESTIMATED_TOTAL _days "+
", Std_estimated_completion_date, std_original_est_cmplt_date from Vwtgs_plans_by_process_step order by SPONSOR_TITLE , Group_pdf_code, Provider_network, Build_type, group_begin_date ";

using (IDbCommand cmd = con. CreateCommand ())
{
Cmd.commandtext = sSQL;
using (DbDataAdapter da = dbf. Createdataadapter ())
{
((IDbDataAdapter) da). SelectCommand = cmd;
using (DataTable dt = new DataTable ())
{
Da. Fill (DT);

ReportDataSource Dataseta = new ReportDataSource ("DataSet", DT);
Report. Datasources.add (Dataseta);
}
}
}
}

Warning[] warnings;
String[] Streamids;
String MimeType;
string encoding;
string extension;
Byte[] bytes = report. Render ("Excel", NULL, out-mimeType, out-encoding, out extension,
Out Streamids, out warnings);
FileStream fs = new FileStream (@ "D:\output.xls", FileMode.Create);
Fs. Write (bytes, 0, bytes. Length);
Fs. Close ();
}

Export the RDL file to an Excel file by LocalReport

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.