我有一个excel文件,如下所示。我想在Excel中使用列值(如SubmissionID == 2)找到一行,然后更新特定行的电子邮件地址
using (XLWorkbook wb = new XLWorkbook(filestream))
{
var ws = wb.Worksheet(1);
var range = ws.RangeUsed();
var lastRow = range.LastRowUsed().RowNumber();
// not able to find the column
using (var rows = ws.RowsUsed(r => r.FirstCell().GetString() == "SubmissionID"))
{
foreach (var row in rows)
{
// Do something with the row...
}
}
}
答案 0 :(得分:1)
我认为你应该使用
using (var rows = ws.RowsUsed(r => r.FirstCell().GetString() == "2"))
或
using (var rows = ws.RowsUsed(r => r.FirstCell().Value == 2))