LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding the End of File (EOF) in Labview

How Can I detect the End of File of an excel spreadsheet using Labview ?
0 Kudos
Message 1 of 15
(8,993 Views)
Have you tried using the "Read From Spreadsheet File.vi"?
0 Kudos
Message 2 of 15
(8,979 Views)

Could you explain what you are looking for?

(The EOF marker is nothing specific to excel and will just give you the file size. You would use the EOF tool from the advanced file palette. Check the online help for more details).

Sima: Read from spreadsheet file reads ascii formatted numeric text files with tabs separating values and linefeeds seperating rows. It cannot read real MS excel files at all.

0 Kudos
Message 3 of 15
(8,973 Views)
Thanks altenbach, I missed that.
0 Kudos
Message 4 of 15
(8,965 Views)

Ok, let me rephrase this Question.

Lets say that I have a VI that is reading an Excel sheet row after the other. How can I detect when it reaches tha last row that contains data? This will help me prevent the VI from reading further blank rows

0 Kudos
Message 5 of 15
(8,955 Views)
Look in the File - Advanced palette.  This is a function called EOF.  This function returns the end of file location as an offset relative to the beginning of the file.  Whenver you read a line in the file (or any portion of the file), check the offset from the read funtion to the value obtained from the EOF function.  If the read offset is greater than or equal to the EOF offset, you have reached the end of file.  The best way to code this is to call EOF before the loop where you are reading in the rows.  Pass the EOF offset output to the loop.  Inside the loop, compare the read offset output to the EOF offset and use the resulting boolean to stop or continue the loop.
- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 15
(8,949 Views)
Are you reading a "real" excel file. How are you reading the lines? Are you using OLE automation of the office toolkit?
0 Kudos
Message 7 of 15
(8,942 Views)

tbob: EOF from the file advanced palette cannot be used with excel. It needs the file Refnum as as input to execute, however the refnums created by the excel File Open VI is not of same data type as that of the EOF VI.

0 Kudos
Message 8 of 15
(8,931 Views)
I've never heard of an "excel" Open File vi.  Is this part of a toolkit?  Does the "excel" Read File give an offset output as to where the file pointer is?  If so, then you could read the entire file and the final offset value should be the EOF marker.
- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 15
(8,919 Views)

tbob:

The Open File VI is not part of any tool kit, it was custom made. Yes, the Read Excel VI can return the current offset being read, but there is no VI that can scan the entire file and return the EOF offset.

0 Kudos
Message 10 of 15
(8,906 Views)