NOPI 、DocX 、Aspose.Woeds.dll、 dll下载

都是苦bi程序员,有干货就好好分享下嘛,动不动就要下载积分~~哼  找NopI系列Dll的不用到处找了,我分享的包里面都有哦~还有Aspose.Woeds.dll 等文件。

链接:https://pan.baidu.com/s/1GKJ4pH09hsoSW0jIySsARA
提取码:jwjc
 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
引用之后,使用该方法读取excel文件 #region 读取Excel public static DataTable ImportExcel(string filePath) { try { //根据路径通过已存在的excel来创建HSSFWorkbook,即整个excel文档 FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //判断文件后缀名是xls,还是xlsx,如果是xls,使用HSSFWorkbook;如果是xlsx,使用XSSFWorkbook XSSFWorkbook workbook = new XSSFWorkbook(file); //获取excel的第一个sheet ISheet sheet = workbook.GetSheetAt(0); DataTable table = new DataTable(); //获取sheet的首行 IRow headerRow = sheet.GetRow(0); if (headerRow == null) headerRow = sheet.GetRow(1); //一行最后一个方格的编号 即总的列数 int cellCount = headerRow.LastCellNum; for (int i = headerRow.FirstCellNum; i < cellCount; i++) { ICell cell = headerRow.GetCell(i); if (cell != null) { DataColumn column = new DataColumn(cell.StringCellValue); table.Columns.Add(column); } } //最后一列的标号 即总的行数 // int rowCount = sheet.LastRowNum; cellCount = table.Columns.Count; for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++) { IRow row = sheet.GetRow(i); if (row == null) continue; DataRow dataRow = table.NewRow(); bool isAdd = false; for (int j = row.FirstCellNum; j < cellCount; j++) { if (row.GetCell(j) == null) continue; //row.GetCell(j).SetCellType(CellType.STRING); if (row.GetCell(j) != null) { if (row.GetCell(j).CellType == CellType.NUMERIC) dataRow[j] = (int)(row.GetCell(j).NumericCellValue); else dataRow[j] = row.GetCell(j).StringCellValue; isAdd = true; } } if (isAdd) table.Rows.Add(dataRow); } workbook = null; sheet = null; return table; } catch (Exception ex) { MessageBox.Show(ex.ToString()); return null; } } #endregion

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值