From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with reading xls file with text inside

Solved!
Go to solution

Dear all,

 

I have a problem reading the excel (xls) file with the first row containing strings of various of length.

 

I wonder how I can ignore the first line and continue reading from the second line.

 

Thank you very much. Smiley Happy

 

Message Edited by powerplay on 07-09-2009 02:46 PM
0 Kudos
Message 1 of 8
(3,212 Views)

How are you reading the .xls file now?  Are you using ActiveX methods?  If so, just define the range you want to read as beginning at row 2.

0 Kudos
Message 2 of 8
(3,206 Views)

Ravens Fan, thanks for your reply.

 

I am using "Read from spreedsheet File" function. 

0 Kudos
Message 3 of 8
(3,202 Views)

Then you are not reading an Excel file.  An excel file is a binary file with a proprietary format.  You actually have a text file that you happened to give an .xls extension to.  And that is a bad idea because .xls implies you have an Excel file.

 

As mentioned numerous times in the forums, the Write to  (Read from) Spreadsheet file functions are poorly named.  When people think spreadsheet, they think Excel.  But these functions don't handle Excel files.  They work on text files that saved in a spreadsheet like format (tab delimited, end of line characters).

 

You will need to open the text file and read 1 line.  Then read the rest of your data.  Convert the string to an array.

 

There may be other ways of doing this.  Search the forums as questions about Read from Spreadsheet file have been asked thousands of times before.

Message Edited by Ravens Fan on 07-09-2009 04:10 PM
0 Kudos
Message 4 of 8
(3,198 Views)

Ravens Fan wrote:

 

Search the forums as questions about Read from Spreadsheet file have been asked thousands of times before.


But who's counting? Smiley Very Happy

 

To question: If it's just the first row that's the problem, you can also just use an Array Subset after reading it to get rid of the first row.

0 Kudos
Message 5 of 8
(3,184 Views)

Ravens, could you kindly label your diagram of each block? I could not find the same block(function) from my Labview. My version is Labview 8.5 Full develop system.

 

Thanks. 

0 Kudos
Message 6 of 8
(3,175 Views)
Solution
Accepted by topic author powerplay

I don't have that VI saved.

 

So here are the names.

 

Across the bottom:  Open File.  Read Text file with Read Lines selected (right click for menu to find it).  Read Text File with Read Lines not selected.  Close File.  At the top is Spreadsheet String to Array.

Message 7 of 8
(3,163 Views)

Ravens Fan

 

thanks a lot, Ravens Fan. You really helped a lot.Smiley Happy

0 Kudos
Message 8 of 8
(3,154 Views)