How do I search for specific text in an Excel worksheet and get the address that the text using C#?

If I was looking for the text “apples”, the functionality will definitely discover the cell that contains apples and return its own handle (i.e., A5).

I am actually looking for a means to hunt for certain message in an Excel piece as well as possess the handle of the tissue that text resides in.

The main thing, is this assumes.Net 4.0 as I utilize skipping arguments for the discover call. , if you are actually utilizing a previous variation you are going to require to pass in misValue for any kind of guideline not utilized.

This becomes part of a much larger job, yet for this particular functionality, I have the capability to open up as well as close the Excel report. I have but to begin creating the search function but, given that to become completely honest, I am actually certainly not specifically sure on also exactly how to go concerning performing this. Yet right here is what I contend this aspect.

This are going to browse in the initial Worksheet of the existing active workbook of an existing Excel treatment.

For accessing the Excel spread sheet I am actually using Excel = Microsoft.Office.Interop.Excel. I have actually been looking all weekend for a dependable technique to do this and also have been actually badly not successful up until now. Any kind of assistance I can easily obtain would be considerably appreciated.

I’m creating a windows application along with c# as well as in one kind I intend to utilize a n succeed documents thus.

In the kind when the individual types the Staff member I.D. in a content package I wan na browse the excel report and based upon the ID series other details for the employee in some various other message containers( label message box, surname content container, standing textbox, as well as food matter text carton).

I am actually creating a plan that is going to permit me to open stand out spreadsheets and obtain some specific information off of all of them. Each piece consists of the very same information that I require, however the details is certainly not constantly in the very same location.

if you take out the FirstOrDefault() after that you will acquire a IEnumerable coming from the provided LINQ inquiry. It is actually always counted on that id is special. When when you contact FirstOrDefault() after that you will definitely get a single row along with that ID. If I.D. is skipping then you will certainly receive a zero datarow.

var app = (Excel.Application)Marshal.GetActiveObject("Excel.Application");
        var wb = app.ActiveWorkbook;
        var ws = wb.Worksheets[1] as Excel.Worksheet;
        var cells = ws.Cells;
        var match = cells.Find("apples", LookAt:=Excel.XlLookAt.xlPart) as Excel.Range;
        var matchAdd = match != null ? match.Address : null;

Leave a Reply

Your email address will not be published. Required fields are marked *