LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find a row number in excel

Solved!
Go to solution

Hi

 

I need help in finding the row number in excel.

 

Actually what i am trying to do is, i am using the scanner to read the barcode(string) then i need to search for the same string in the excel file(my datas are saved as like this for ex:In row 5, in column 1 i have the string(West) from column 2 to column 10 i will have some values). Now when my string matches with West its going to display the values from column 2 to 10, so i have to find at which row number the string West matched.

 

Thanks

0 Kudos
Message 1 of 9
(6,340 Views)

I haven't worked this out, but would approach it this way.

 

Read the file from spreadsheet as text...it is then a 2D array of text.  In a for loop, index through the array until the first column = the text word you are searching for (West).  The i value will be the correct index to the rest of the data on that row,

Use the i to index the array again and now convert all the columns to numbers from text...

 

That's what I would try to do...

 

Ben showed this to someone on the forum in the last few days and I will see if I can find a reference to that.

0 Kudos
Message 2 of 9
(6,323 Views)

Thanks Hummer

 

The problem is we have values saved in excel so i ahve to read from excel,

0 Kudos
Message 3 of 9
(6,302 Views)
Why is that a problem? There's thousands of posts on using ActiveX for Excel including the Excel Board. Read the spreadsheet into a 2D array as mentioned. Instead of the loop, you could use the Index Array function to get column 0 and use the Search 1D Array function.
0 Kudos
Message 4 of 9
(6,285 Views)
Check out the ExcelExamples.llb (not sure if this comes with standard installation). But there are a lot of VI's already made that you can import to your pallette which will let you do this
0 Kudos
Message 5 of 9
(6,272 Views)

Thanks All

 

I have tried the above suggestions, it works fine for .txt files but i am getting some erroe when it is .xls file

 

Thanks

0 Kudos
Message 6 of 9
(6,259 Views)

Go back and read through the Excel board again.

 

You are making what is a very common mistake since the Read from Spreadsheet File is a poorly named, confusing function.  It only reads text files that are structured in a spreadsheet like format.  It does not read .xls files which are a proprietary Microsoft format for the Excel spreadsheet program.  If you think about it, an .xls file has to store far more information than just the values stored in the cells.  It has to store formating and formula information.  It has multiple sheets.  It holds visual basic code. .....  A simple Read from Spreadsheet file function doesn't know how to sort through all that information.

 

As Dennis said, you need to use ActiveX functions.

0 Kudos
Message 7 of 9
(6,256 Views)

Thanks Ravens

 

Its working now.Thanks All

0 Kudos
Message 8 of 9
(6,251 Views)
Solution
Accepted by topic author Veeru

Searching through the forums helps a lot. Here is a discussion where I already solved your problem.

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=200494&jump=true

 

For more information and some sample VI's and tool kits, you can go to the excel board




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 9 of 9
(6,241 Views)