【原创】C#导出数据到EXCEL方法谈(附实例源码和超级无敌详细讲解)

上传者: smallwhiteyt | 上传时间: 2020-01-03 11:34:50 | 文件大小: 561KB | 文件类型: rar
具体内容请参考我的BLOG:http://blog.csdn.net/smallwhiteyt/archive/2009/11/08/4784771.aspx 如果你耐心仔细看完本文,相信以后再遇到导出EXCLE操作的时候你会很顺手觉得SO EASY,主要给新手朋友们看的,老鸟可以直接飘过了,花了一晚上的时间写的很辛苦,如果觉得对你有帮助烦请留言支持一下,我会写更多基础的原创内容来回报大家。 C#导出数据到EXCEL表格是个老生常谈的问题了,写这篇文章主要是给和我一样的新手朋友提供两种导出EXCEL的方法并探讨一下导出的效率问题,本文中的代码直接就可用,其中部分代码参考其他的代码并做了修改,抛砖引玉,希望大家一起探讨,如有不对的地方还请大家多多包涵并指出来,我也是个新手,出错也是难免的。 首先先总结下自己知道的导出EXCEL表格的方法,大致有以下几种,有疏漏的请大家补充。 1.数据逐条逐条的写入EXCEL 2.通过OLEDB把EXCEL做为数据源来写 3.通过RANGE范围写入多行多列内存数据到EXCEL 4.利用系统剪贴板写入EXCEL 好了,我想这些方法已经足够完成我们要实现的功能了,方法不在多,在精,不是么?以上4中方法都可以实现导出EXCEL,方法1为最基础的方法,意思就是效率可能不是太高,当遇到数据量过大时所要付出的时间也是巨大的,后面3种方法都是第一种的衍生,在第一种方法效率低下的基础上改进的,这里主要就是一个效率问题了,当然如果你数据量都很小,我想4种方法就代码量和复杂程度来说第1种基本方法就可以了,或当你的硬件非常牛逼了,那再差的方法也可以高效的完成也没有探讨的实际意义了,呵呵说远了,本文主要是在不考虑硬件或同等硬件条件下单从软件角度出发探讨较好的解决方案。

文件下载

资源详情

[{"title":"( 40 个子文件 561KB ) 【原创】C#导出数据到EXCEL方法谈(附实例源码和超级无敌详细讲解)","children":[{"title":"C#导出数据到EXCEL方法谈(附实例源码和超级无敌详细讲解)","children":[{"title":"【原创】C#导出数据到EXCEL方法谈(附实例源码和超级无敌详细讲解).doc <span style='color:#111;'> 80.50KB </span>","children":null,"spread":false},{"title":"测试数据源.xls <span style='color:#111;'> 2.37MB </span>","children":null,"spread":false},{"title":"DatagridviewToExcel","children":[{"title":"DatagridviewToExcel.suo <span style='color:#111;'> 7.50KB </span>","children":null,"spread":false},{"title":"DatagridviewToExcel","children":[{"title":"Form1.cs <span style='color:#111;'> 20.37KB </span>","children":null,"spread":false},{"title":"bin","children":[{"title":"Debug","children":[{"title":"DatagridviewToExcel.vshost.exe <span style='color:#111;'> 13.99KB </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.pdb <span style='color:#111;'> 21.50KB </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.vshost.exe.manifest <span style='color:#111;'> 490B </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.exe <span style='color:#111;'> 8.50KB </span>","children":null,"spread":false}],"spread":true},{"title":"Release","children":[{"title":"office.dll <span style='color:#111;'> 218.55KB </span>","children":null,"spread":false},{"title":"Microsoft.Vbe.Interop.dll <span style='color:#111;'> 62.59KB </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.vshost.exe <span style='color:#111;'> 13.99KB </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.pdb <span style='color:#111;'> 31.50KB </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.vshost.exe.manifest <span style='color:#111;'> 490B </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.exe <span style='color:#111;'> 212.00KB </span>","children":null,"spread":false},{"title":"Microsoft.Office.Interop.Excel.dll <span style='color:#111;'> 1.05MB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"DatagridviewToExcel.csproj <span style='color:#111;'> 4.10KB </span>","children":null,"spread":false},{"title":"obj","children":[{"title":"Debug","children":[{"title":"DatagridviewToExcel.Form1.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.Properties.Resources.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.csproj.GenerateResource.Cache <span style='color:#111;'> 847B </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.csproj.FileListAbsolute.txt <span style='color:#111;'> 1024B </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.pdb <span style='color:#111;'> 21.50KB </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"DatagridviewToExcel.exe <span style='color:#111;'> 8.50KB </span>","children":null,"spread":false}],"spread":true},{"title":"Release","children":[{"title":"DatagridviewToExcel.Form1.resources <span style='color:#111;'> 97.89KB </span>","children":null,"spread":false},{"title":"ResolveAssemblyReference.cache <span style='color:#111;'> 8.46KB </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.Properties.Resources.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.csproj.GenerateResource.Cache <span style='color:#111;'> 847B </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.csproj.FileListAbsolute.txt <span style='color:#111;'> 1.37KB </span>","children":null,"spread":false},{"title":"DatagridviewToExcel.pdb <span style='color:#111;'> 31.50KB </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"DatagridviewToExcel.exe <span style='color:#111;'> 212.00KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"Properties","children":[{"title":"Resources.Designer.cs <span style='color:#111;'> 2.82KB </span>","children":null,"spread":false},{"title":"Settings.settings <span style='color:#111;'> 249B </span>","children":null,"spread":false},{"title":"Resources.resx <span style='color:#111;'> 5.48KB </span>","children":null,"spread":false},{"title":"Settings.Designer.cs <span style='color:#111;'> 1.08KB </span>","children":null,"spread":false},{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.36KB </span>","children":null,"spread":false}],"spread":true},{"title":"Program.cs <span style='color:#111;'> 500B </span>","children":null,"spread":false},{"title":"ICO.ico <span style='color:#111;'> 97.34KB </span>","children":null,"spread":false},{"title":"Form1.Designer.cs <span style='color:#111;'> 7.40KB </span>","children":null,"spread":false},{"title":"Form1.resx <span style='color:#111;'> 152.57KB </span>","children":null,"spread":false}],"spread":true},{"title":"DatagridviewToExcel.sln <span style='color:#111;'> 947B </span>","children":null,"spread":false}],"spread":true},{"title":"DatagridviewToExcel.exe <span style='color:#111;'> 212.00KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}]

评论信息

  • qxhuan :
    还是有用的,不过做不了定时写入数据
    2019-12-13
  • xiaoqiang8_8 :
    非常不错,很实用,下载方便,平台很好,推荐,谢谢分享。
    2019-06-04
  • xecho115 :
    很赞,很详细
    2018-10-21
  • ljy00k :
    能用也挺全的
    2018-07-05
  • rockmen2 :
    下载了没开始下载
    2018-04-13

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明