LINQ and ExcelQueryFactory



我在从第一个单元格中没有数据输入的特殊工作表中选择所有行时遇到问题。

我正在使用ExcelQueryFactory来检索数据。

这是我到现在为止的代码。。。

// get the worksheets out of the source file 
var sourceFactory = new ExcelQueryFactory(fullFileName);
            
// we search by regex function for (##)
var regexSearchTerm = new Regex(@"(d+)");
// get a list of worksheets whose have a number in it's name
var worksheets = (from sheets in sourceFactory.GetWorksheetNames() 
                  where regexSearchTerm.Matches(sheets).Count > 0 
                  select sheets).ToList();
// determine all the rows which has an item in the first cell
foreach (var wsheetItem in worksheets)
{
  var affectedRows = < the linq query I am searching for >
}

现在的问题是,我没有得到一个有效的linq语句来选择行中第一个单元格为空的行。

我希望有人能帮我。。。

提前谢谢。

要选择第一个单元格为空的所有行,可以使用以下代码:

IEnumerable<Row> affectedRows =
      from row in wsheetItem.Descendants<Row>()
      where (row.Descendants<Cell>().First().CellValue == null)
      select row;

相关内容

  • 没有找到相关文章

最新更新