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 using : read from spreadsheet file

Solved!
Go to solution

Hi,

 

I have 2 problems using read from spreadsheet file :

 

1) when using .txt file I can only get the first column and not the second one (although I have chosen the correct output...)

2) It doesn't work at all when using my .xls file

 

I must be doing something wrong but can't find what....

 

Would anybody have an idea ?

 

I have attached the .VI and my two files.

 

Thanks

 

User

Download All
0 Kudos
Message 1 of 7
(3,882 Views)

In your "Read From Spreadsheet File", you have your delimiter set to "\s", meaning that the VI expects the delimiter between numbers to be a space.

 

Have you actually looked at the formatting of your text file?  Evidently not.  The delimiter in your text file is a tab...not a space. 

 

Delete the "\s" input to the VI (a tab delimiter is the default delimiter for "Read From Spreadsheet File") and it'll work fine.  I just did it, and sure enough, it works fine.

 

The reason that "Read From Spreadsheet" cannot read your .xls file is because a file created with Excel (that is, an .xls file) is a custom Microsoft format, and not a standard text file.  In order to read an .xls file directly, you'll have to use ActiveX.

 

Hope that helps.

d

Message Edited by DianeS on 02-14-2010 07:46 PM
0 Kudos
Message 2 of 7
(3,872 Views)

It is a bit more to it than that.

 

I saw the tab vs. space delimiter problem.  I changed it to \t for a tab delimiter, but it still didn't work.

 

The reason?  The OP has the constant showing \t in Normal display which is a delimiter of backslash t.  It needs to show \t in \codes display to actually represent a tab.

Message 3 of 7
(3,867 Views)

Yes.  Good catch.  Thanks!

 

The OP could also wire in a tab constant from the strings palette...I did that just for fun and that also works.

0 Kudos
Message 4 of 7
(3,853 Views)

Hi Diane and Ravens fan,

 

Thanks for your answers.

 

I have attached the VI that works fine with the .xls that is created and saved to with Labview when acquiring my data.

 

 I don't need this for my program but I would like to understand why is this : when creating a file with Excel it only works when the file is saved in .txt but not when saved as a excel file....

 

User 

0 Kudos
Message 5 of 7
(3,730 Views)
Native excel files are not supported by spreadsheet functions. You have to use a activex.
Message 6 of 7
(3,727 Views)
Solution
Accepted by topic author User_1979

A native Excel file is NOT a text file.  It's a custom file format created by Microsoft.  That is why you have to use ActiveX to interact with it.

 

The "Spreadsheet" file functions found in LabVIEW work with text files (tab-delimited, CSV, etc.).  Text files are a more generic format which can be read by programs like Notepad.  Ever tried to use Notepad to open a .xls file?  It doesn't work.  Excel can open a text file because it's a generic format.

 

So, even though everyone automatically thinks "Excel" when they see the word "Spreadsheet", the two are not synonymous.  In LabVIEW's case, "Spreadsheet" refers to a delimited text file.

 

Does that make sense?

Message 7 of 7
(3,706 Views)