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
{
static void Main(string[] args)
{
List<string> list = GetExcelColumnValue(@"D:\UniuAndroid5.6.2\plan\配置表\excel\t_equip.xlsx", , ); for (int i = ; i < list.Count; ++i)
{
Console.WriteLine(list[i]);
} Console.ReadKey();
} /// <summary>
/// 读取Excel表格列数据
/// </summary>
/// <param name="path">Excel表格所在的路径</param>
/// <param name="sheetIndex">需要读取的Sheet页码序号</param>
/// <param name="columnIndex">需要读取的列序号</param>
/// <returns></returns>
static List<string> GetExcelColumnValue(string path, int sheetIndex, int columnIndex)
{
List<string> list = new List<string>(); FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
ExcelPackage excel = new ExcelPackage(fileStream);
ExcelWorksheet sheet = excel.Workbook.Worksheets[sheetIndex]; try
{
for (int i = ; i <= sheet.Dimension.End.Row; i++)
{
var cell = sheet.Cells[i, columnIndex];
if (cell != null && cell.Value != null)
list.Add(cell.Value.ToString());
}
}
catch
{
throw;
}
finally
{
sheet.Dispose();
excel.Dispose();
fileStream.Dispose();
} return list;
}
}
}

读取结果部分截图:

C#读取Excel表格的数据的更多相关文章

  1. C#读取Excel表格中数据并返回datatable

    在软件开发的过程中,经常用到从excel表格中读取数据作为数据源,以下整理了一个有效的读取excel表格的方法. DataTable GetDataTable(string tableName,str ...

  2. 读取Excel表格中数据原型

    写下这篇博客来记录自己的工作,这部分功能是读取Excel表格中的数据,并通过c#中的datagridview控件将读取的数据显示出来.为了方便用户,我设计了一个read按钮,用户点击这个按钮,会弹出打 ...

  3. 读取Excel表格日期类型数据的时候

    用POI读取Excel数据:(版本号:POI3.7) 1.读取Excel 2.Excel数据处理: Excel存储日期.时间均以数值类型进行存储,读取时POI先判断是是否是数值类型,再进行判断转化 1 ...

  4. 利用 pandas库读取excel表格数据

    利用 pandas库读取excel表格数据 初入IT行业,愿与大家一起学习,共同进步,有问题请指出!! 还在为数据读取而头疼呢,请看下方简洁介绍: 数据来源为国家统计局网站下载: 具体方法 代码: i ...

  5. python2读取EXCEL表格内的数据时碰到的问题

    一,今天在剥离自动化的测试数据时,发生了一个错误,错误显示读取不到某个单元格的数据. 因为我使用的是python2,正好那一个单元格出现的是中文汉字,再者通过查看报错日志,让我了解到错误的原因. di ...

  6. go读取excel表格数据

    go读取excel表格数据 使用工具 github.com/Luxurioust/excelize 百度到的都是使用这个 实际上已经改名了 github.com/360EntSecGroup-Skyl ...

  7. Java读取excel表格

    Java读取excel表格 一般都是用poi技术去读取excel表格的,但是这个技术又是什么呢 什么是Apache POI? Apache POI是一种流行的API,它允许程序员使用Java程序创建, ...

  8. C# 读取Excel表格内容,以及NPOI的使用

    在实际的开发中,我们可能需要读写word或者Excel的内容,在我开发的项目中,需要读取Excel的内容,并将相对应的内容存储到数据库中,这里简单跟大家分享一下,希望能够帮助一些人. 我相信在读写wo ...

  9. 利用pandas读取Excel表格,用matplotlib.pyplot绘制直方图、折线图、饼图

    利用pandas读取Excel表格,用matplotlib.pyplot绘制直方图.折线图.饼图 数据: 折线图代码: import  pandas  as pdimport  matplotlib. ...

随机推荐

  1. Codeforces 837D Round Subset - 动态规划 - 数论

    Let's call the roundness of the number the number of zeros to which it ends. You have an array of n ...

  2. Vue学习【第一篇】:Vue初识与指令

    什么是Vue 什么是Vue Vue.js是一个渐进式JavaScript框架它是构建用户界面的JavaScript框架(让它自动生成js,css,html等) 渐进式:vue从小到控制页面中的一个变量 ...

  3. Visual Studio Code 的 launch.json 解析

    { "version": "0.2.0", "configurations": [ { "name": "(g ...

  4. 关于link标签的用法, 不声明rel=stylesheet则无效? 在ff中必须声明rel属性!

    void 无效的, 空的; invalid: 无效的, void 和 invalid 在表示无效的时候, 是一样的, 等同的 the treaty (条约) was declared invalid ...

  5. hihoCoder week8 状态压缩·一

    状态压缩  写了两个半小时  太菜了 题目链接 https://hihocoder.com/contest/hiho8/problem/1 #include <bits/stdc++.h> ...

  6. How to search for ? (question mark) in Excel

    The ? is a wildcard which represents a single character, and the * is a wildcard character that repr ...

  7. MVC 之 初识(一)

    创建一个mvc项目,在项目中会startup.cs文件,startup文件主要是将项目寻找一个宿主 过去,项目一般都是寄宿在iis上的,通过owin可以寄宿到不同的宿主. 可以关闭owin:<a ...

  8. Android中EditText焦点问题

    https://www.jianshu.com/p/3d31d681f4bc 问题:当EditText失去焦点时做内容校验 场景:用户编辑EditText将内容清空,当点击空白地方时关闭软键盘,同时校 ...

  9. SQLite EF Core Database Provider

    原文链接 This database provider allows Entity Framework Core to be used with SQLite. The provider is mai ...

  10. mybatis批量更新数据参考

    https://blog.csdn.net/xyjawq1/article/details/74129316