Is it possible to do a find in ClosedXML? I looked through their documentation and there is no record of it. How else can I look at all the methods included in ClosedXML, so I can find some of these things on my own?
Asked
Active
Viewed 3,012 times
3
-
You can search using `string` methods if you can read content from the Excel (I didn't use ClosedXML). – elirandav Feb 23 '17 at 17:29
-
@KernelMode, Yeah I can do that with a loop but that will take much longer. I was hoping I did not have to. – djblois Feb 23 '17 at 17:42
-
can you give a concrete example what you're after? It looks like this link should get you going in the right direction: https://github.com/closedxml/closedxml/wiki/Better-lambdas – sous2817 Feb 23 '17 at 17:48
-
@KernelMode, That is looking inside an individual cell for a string. I want to look at multiple cells to see if the string exists in any of them. – djblois Feb 23 '17 at 17:55
1 Answers
6
The link given by sous2817 shows the right way in ClosedXML. Something like this:
sheet.CellsUsed(cell => cell.GetValue<string>() == searchstring)
or
sheet.CellsUsed(cell => cell.GetValue<string>().Contains(searchstring))
And yes, this is a relatively expensive operation for large sheets.