.net DataSet 导出到Excel】的更多相关文章

public void CreateExcel(DataSet ds, string typeid, stringFileName)        {           HttpResponse resp;            resp =Page.Response;           resp.ContentEncoding =System.Text.Encoding.GetEncoding("GB2312");           resp.AppendHeader(&quo…
using System; using System.IO; using System.Data; using System.Reflection; using System.Diagnostics; using System.Configuration; using System.Collections; using Excel; namespace thscjy {  ///  /// 套用模板输出Excel,生成xls文件和html文件  /// Author: Liu Wen  ///…
之前网上查找了很多关于这类的代码.要不是中文乱码,要不是就是太复杂.这个是我用过最好用的. //ds为数据源,filename为保存的文件名 publicvoidCreateExcel(DataSet ds,stringFileName) { //设置信息 HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType="application/vnd.ms-excel"; HttpConte…
//读取临时文件    GYYW.DA.Common.Base_SqlDataBase daBZDM = new GYYW.DA.Common.Base_SqlDataBase();    DataSet dsBZDM = daBZDM.GetDataSetBySql("select QCDM,MC,GG from WG_BZDM where QCDM like '02%'");        //同时将虚拟目录下的Data作为临时文件目录.    string urlPath = H…
public static void ExportToExcel(DataSet source, string fileName) { System.IO.StreamWriter excelDoc = new System.IO.StreamWriter(fileName); ExportToExcel(source, excelDoc); } public static void ExportToExcel(DataTable dtSource, string fileName) { Dat…
依旧是留下代码防止以后忘记 protected void Export_Click(object sender, EventArgs e) { DataSet data = "" //数据获取 DataTable dt = data.Tables[]; DataRow[] myrow = dt.Select(); Response.Clear(); Response.ContentType = "application/vnd.ms-excel"; Response…
Web项目中,很多时候须要实现将查询的数据集导出为Excel文档的功能,很多时候不希望在工程中添加对Office组件相关的DLL的引用,甚至有时候受到Office不同版本的影响,导致在不同的服务器上部署后功能受限,或和其它项目冲突,那么,使用这种简单粗暴的方式,可能会解决部分猿类灵长动物的烦恼忧愁. /// <summary> /// DataSet导出到Excel文件(多个Sheet) /// </summary> /// <param name="dataSet…
/// <summary> /// DataSet导出到Excel的MemoryStream /// </summary> /// <param name="dtSource">源DataSet</param> public static MemoryStream DataSetToExcel(DataSet ds) { XSSFWorkbook workbook = new XSSFWorkbook(); ; k < ds.Tab…
最近工作中需要做一个把用户信息作为excel导出的功能,就顺便整理搜集了一些常用的导出文件的源代码,以供以后不时之需,也希望能给大家带来一些方便 一.DataSet数据集内数据转化为Excel // 作用:把DataSet数据集内数据转化为Excel文件 // 描述:这些关于Excel的导出方法,基本可以实现日常须要,其中有些方法可以把数据导出后 // 生成Xml格式,再导入数据库! // 备注:请引用Office相应COM组件,导出Excel对象的一个方法要调用其中的一些方法和属性. publ…
using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Windows.Forms; using System.Reflection; namespace DMS { /// <summary> /// C#操作Excel类 /// </summary> class ExcelOperate { //法一 //public bool Data…