因为前一段时间公司做项目的时候,用到了Excel导入和导出,然后自己找了个插件Epplus进行操作,自己将当时的一些代码抽离出来写了一个帮助类. 因为帮助类是在Epplus基础之上写的,项目需要引用Epplus.dll.自己基础不是很扎实,有问题的地方欢迎指导. 1.用法,默认excel第一列是头部信息. public class UserInfo : XlsRow { public int id { get; set; } public string username { get; set;
using (ExcelPackage ep = new ExcelPackage(new FileInfo(path))) { ExcelWorksheet ws = ep.Workbook.Worksheets[]; //第1张Sheet 这个用EPPlus 读取excel,代码出错, the given key is not present in the dictionary 原来是因为用wps编辑过的原因. 用Excel重新保存一次就可以了.
1.创建工程后,需要下载 EPPlus.dll 添加到工程中,这里有一个下载地址:https://download.csdn.net/download/myunity/10784634 2.下面仅实现读取Excel表格的列数据: using System; using System.Collections.Generic; using System.IO; using OfficeOpenXml; namespace ConsoleApplication1 { class Program { s