问题描述
是否可以使用 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 的集合.
问题描述
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.