gpt4 book ai didi

c# - 使用 EPPlus 和 Linq 从 Excel 获取单元格值

转载 作者:行者123 更新时间:2023-12-03 02:55:25 28 4
gpt4 key购买 nike

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

我有一个包含 3 列的 Excel 工作表

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

现在我想返回电子邮件地址,其中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 的集合。

关于c# - 使用 EPPlus 和 Linq 从 Excel 获取单元格值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13857559/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com