当前位置: 移动技术网 > IT编程>开发语言>.net > 让 .NET 更方便的导入导出 Excel

让 .NET 更方便的导入导出 Excel

2018年11月23日  | 移动技术网IT编程  | 我要评论

毕业那天我们失业,广西浦北天天网,太湖字谜彩酷酷caikuku

让 .net 更方便的导入导出excel

intro

因为前一段时间需要处理一些 excel 数据,主要是导入/导出操作,将 excel 数据转化为对象再用程序进行处理和分析,没有找到比较满意的库,于是就自己造了一个轮子,屏蔽掉了 xlsx 与 xls 的差别,屏蔽了 npoi 操作 excel 的细节,提供简单容易上手的 api。

导入/导出

直接添加 nuget 包引用 weihanli.npoi

根据 excel 文件获取一个 iworkbook 对象,支持 *.xls/*.xlsx

iworkbook workbook = excelhelper.loadexcel("excelfilepath");

将 excel 文件的第一个 sheet 里的内容转成 list 对象

list<tentity> entitylist = excelhelper.toentitylist<tentity>("excelfilepath");

将 excel 文件的第一个 sheet 里的内容转成 datatable 对象

datatable datatable = excelhelper.todatatable("excelfilepath");

将 list 对象导出到 excel 字节数组

list<tentity> entitylist = excelhelper.toentitylist<tentity>("excelfilepath");

entitylist.toexcelbytes();

将 list 对象导出到 excel 文件

list<tentity> entitylist = excelhelper.toentitylist<tentity>("excelfilepath");

entitylist.toexcelfile("excelfilepath");

more

想要更多自定义选项,参考示例项目,或者给我提 issue

contact

如果使用过程中有遇到什么问题,欢迎与我联系。

contact me:

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网