gpt4 book ai didi

c# - LINQ 和 ExcelQueryFactory

转载 作者:太空宇宙 更新时间:2023-11-03 15:44:41 25 4
gpt4 key购买 nike

我无法从第一个单元格中没有数据条目的特殊工作表中选择所有行。

我正在使用 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;

关于c# - LINQ 和 ExcelQueryFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28612826/

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