使用EPPlus和Linq从excel获取单元格值 [英] Get a cell value from excel using EPPlus and Linq

查看:340
本文介绍了使用EPPlus和Linq从excel获取单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用EPPlus和Linq从excel表格中获取单元格值? 示例:

Is it possible to get a cell value from excel sheet using EPPlus and Linq? Example:

我有一个3列的Excel工作表

I have an excel sheet with 3 columns

Column 1 = Userid
Column 2 = Email address
Column 3 = Full name

现在,我想返回电子邮件地址,其中 userid = x

Now i would like to return the email address where userid = x

我希望现在更加清楚.

推荐答案

假设Column 1aColumn 2b:

var sheet = excelPackage.Workbook.Worksheets[sheetname_orSheetIndex];
var objs = from cell in sheet.Cells["a:a"]        // a:a is the column a, Userid
           where cell.Value.ToString().Equals(x)  // x is the input userid
           select sheet.Cells[cell.Start.Row, 2]; // 2 is column b, Email Address

它将起作用! 它将返回ExcelRange的集合.

It will work! Edited: It will return the collection of ExcelRange.

这篇关于使用EPPlus和Linq从excel获取单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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