LINQ和ExcelQueryFactory
我有问题,从第一个单元格中没有数据input的特殊工作表中select所有行。
我正在使用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语句来select行中的第一个单元格是空的行。
我希望有人能帮助我…
提前致谢。
要select第一个单元格为空的所有行,可以使用以下代码:
IEnumerable<Row> affectedRows = from row in wsheetItem.Descendants<Row>() where (row.Descendants<Cell>().First().CellValue == null) select row;