c# ASP.Net 使用开源免费类库操作Excel

 

主要找到以下类库:

  1. MyXls(http://sourceforge.net/projects/myxls/)
  2. Koogra(http://sourceforge.net/projects/koogra/)  
  3. ExcelLibrary(http://code.google.com/p/excellibrary/)
  4. ExcelPackage(http://excelpackage.codeplex.com/)
  5. EPPlus(http://epplus.codeplex.com/)
  6. LinqToExcel(http://code.google.com/p/linqtoexcel/)
  7. NetOffice(http://netoffice.codeplex.com/) 需安装Office Excel

从1-6的类库均不需要安装Office,不使用Office COM组件;而NetOffice需要安装Office,它提供的是与Office COM组件差不多的功能。

 

ASP.NET MVC File Management
http://file.codeplex.com/

 

 

Excel2Object

Excel 与 Object 互相转换

使用的NPOI

https://github.com/tonyqus/npoi

 

  1. EPPlus(http://epplus.codeplex.com/)
protected void UploadButton_Click(Object sender, EventArgs e) { if (FileUpload1.HasFile && Path.GetExtension(FileUpload1.FileName) == ".xlsx") { using (var excel = new ExcelPackage(FileUpload1.PostedFile.InputStream)) { var tbl = new DataTable(); var ws = excel.Workbook.Worksheets.First(); var hasHeader = true; // adjust accordingly // add DataColumns to DataTable foreach (var firstRowCell in ws.Cells[1, 1, 1, ws.Dimension.End.Column]) tbl.Columns.Add(hasHeader ? firstRowCell.Text : String.Format("Column {0}", firstRowCell.Start.Column)); // add DataRows to DataTable int startRow = hasHeader ? 2 : 1; for (int rowNum = startRow; rowNum <= ws.Dimension.End.Row; rowNum++) { var wsRow = ws.Cells[rowNum, 1, rowNum, ws.Dimension.End.Column]; DataRow row = tbl.NewRow(); foreach (var cell in wsRow) row[cell.Start.Column - 1] = cell.Text; tbl.Rows.Add

转载于:https://www.cnblogs.com/taoqianbao/p/3898296.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值