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

本文是小编为大家收集整理的关于使用EPPlus和Linq从excel获取单元格值的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

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

我有一个 3 列的 Excel 表格

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

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

我希望现在更清楚了.

推荐答案

假设Column 1是a,Column 2是b:

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 的集合.

本文地址:https://www.itbaoku.cn/post/1556740.html

问题描述

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

I have an excel sheet with 3 columns

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

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

I hope it's more clear now.

推荐答案

Suppose Column 1 is a, Column 2 is b:

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

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

相关标签/搜索