通过LocalReport将rdl文件导出数据到excel文件

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();
}

时间: 2024-10-05 23:31:26

通过LocalReport将rdl文件导出数据到excel文件的相关文章

CodeIgniterCodeigniter+PHPExcel导出数据到Excel文件

解压压缩包里的Classes文件夹中的内容到application\libraries\目录下,目录结构如下:--application\libraries\PHPExcel.php--application\libraries\PHPExcel(文件夹)修改application\libraries\PHPExcel\IOFactory.php文件--将其类名从PHPExcel_IOFactory改为IOFactory,遵从CI类命名规则.--将其构造函数改为public $this->loa

【代码实现】PHP导入Excel和导出数据为Excel文件

文章来源:PHP开发学习门户 地址:http://www.phpthinking.com/archives/560 有时需要将Excel表格的数据导入到mysql数据库中,我们使用PHP的一个开源项目PHP-ExcelReader可以轻松实现Excel的导入.另外将mysql数据导出为Excel与本站上篇文章中导出CSV一样,只是将逗号分割符换成制表符,并修改header信息就可以了. 下载源码 本文中,我们沿用本站文章:使用PHP导入和导出CSV文件 中实例的数据表以及html. 1.导入XL

使用PHP导入Excel和导出数据为Excel文件

1.导入XLS PHP-ExcelReader这是一个开源的项目,主要是来解析excel的文件,您可以到http://sourceforge.net/projects/phpexcelreader获取最新版的源码.下载之后解压,主要用到excel文件夹里面的两个文件reader.php和oleread.inc. 导入Xls处理流程:选择xls文件->上传xls文件到服务器->通过PHP-ExcelReader解析excel->批量入库.  include_once("excel

NPOI读取excel文件导出数据, 而此时文件正在打开中抛异常怎么办

项目中需要用到一些数值表格, 方便起见都是用excel来的. 而如果excel正打开中, 直接使用npoi制作的工具来导出数据的话, 在这一行将会异常: workbook = new XSSFWorkbook(filepath); 其实只是读取的话, 并不需要获得它完整的使用权限, 那么用file.open然后再new workbook行不行? 也不行. 其实看那些excel其他软件的做法就很简单了, 首先执行一次copy string tmpFile = "~tooltmp.xlsx"

导出数据到Excel文件

第一种方式: [HttpPost] public ActionResult ExportPageOrder(FormCollection form) { try { Response.Charset = "GB2312"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); Response.ContentType = "application/vnd.ms-exce

导出数据为Excel文件---Controller

@Controller @RequestMapping("/vehmileage") public class VehMileageController extends BaseController{ private static final Logger LOG=Logger.getLogger(VehMileageController.class); private static final String FILE_NAME="里程导出"; private st

导出数据为Excel文件-JS

var params=''; if(vahiclePlate!=''){ params='lpn'+vahiclePlate; } if(startTime!=''){ params=params==''?'startTime='+startTime:(params+'&')+'startTime='+startTime; } .....搜索条件 if(params!=''){ params+='&'+'fileName=车队行程统计导出'; params+='&'+'lpnNam

java Servlet导出数据到Excel文件

package com.lbc.excel.servlet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet

导出数据为Excel文件---Client2

public class ExportVehMileageClients extends RestfulWSClient<ServiceResponse>{ private static final Logger LOG=Logger.getLogger(ExportVehMileagesClient.class); private static final String WSURL=GET_EXPORTVEHMILEAGES_URL; private static final String