简体   繁体   中英

Iterate through all the data in excel file and find specific text

I need to generate a excel file which range is not known, so I can't iterate through fixed range of columns/rows. So is there a way to iterate through the used cells in order to find all cells with text "V" using ClosedXML or OpenXML?

您必须选择EPPlus,它是可与Excel一起使用的开放源代码库,与ClosedXML或OpenXML相比都具有不错的速度。

In ClosedXML you can use something like this:

using (var cells = worksheet.CellsUsed(c => c.GetString() == "V"))
{
    foreach (var cell in cells)
    {
        // Do something with the cell ...
    }
}

https://github.com/ClosedXML/ClosedXML/pull/399上有一个拉取请求,例如:

 foundCells = ws.Search("searchText", CompareOptions.OrdinalIgnoreCase);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM