使用EPPlus读取Excel电子表格 [英] Reading Excel spreasheet using EPPlus

查看:77
本文介绍了使用EPPlus读取Excel电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以为我指出如何阅读Excel电子表格的正确方向,使用EPPlus和MVC遍历所有行和列以获取价值吗?这样的票价,我看到了创建电子表格的示例,但是在打开excel文件并从中读取值时未找到任何内容.任何帮助将不胜感激.

Could someone point me in the right direction on how to read a Excel spreasheet, loop through all the rows and columns to retreive value using EPPlus and MVC? So fare I see examples to create a spreasheet, but did not find any on opening an excel file and read values from it. Any help would be appreciated.

TIA 苏..

推荐答案

简单示例

// Get the file we are going to process
var existingFile = new FileInfo(filePath);
// Open and read the XlSX file.
using (var package = new ExcelPackage(existingFile))
{
    // Get the work book in the file
    var workBook = package.Workbook;
    if (workBook != null)
    {
        if (workBook.Worksheets.Count > 0)
        {
            // Get the first worksheet
            var currentWorksheet = workBook.Worksheets.First();

            // read some data
            object col1Header = currentWorksheet.Cells[1, 1].Value;

这篇关于使用EPPlus读取Excel电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆