LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Get Data returns -1 instead of "True"

I'm using the Excel Get Data.vi from the report generation toolkit and see a -1 returned instead of the actual text value of "True"

 

I've tried formatting the Excel spreadsheet to "Text" to try and force it, but it always returns -1.

 

Any suggestions?

 

excel entry.jpg

 

 

 

ExcelCodeSnippit.jpg

 

 

 

Thanks!

0 Kudos
Message 1 of 6
(4,215 Views)

Almost forgot - Using Labview 2010 SP1

0 Kudos
Message 2 of 6
(4,214 Views)

It's because True in Excel is not text.  It is a boolean/numerical value that converts to -1.  Likewise, False is not text, but a value that converts to 0.

 

If you type true or false in lower case in Excel, you'll see it automatically converts to all upper case.  If it was text, it would remain exactly how you typed it.

 

If you want it to be text, format the cell in Excel to be text format instead of general or numeric.

 

Message 3 of 6
(4,198 Views)

Thanks for the reply...  but the cell format (the entire workbook) is already formatted for Text.

 

This only happens with True.   False shows up as "False" when detected.

 

I've highlighed the cell that contains "True" so you can see that it is set to "Text".   I've also added the "False" with the returned data below.

 

 

Thanks.

 

ExcelEntryII.jpg

 

ExcelReturnedData.jpg

0 Kudos
Message 4 of 6
(4,180 Views)

Ok... it started detecting as a text cell after I edited the Excel sheet.   I replaced "TRUE" with "TRUE" and I could see the text shifted to the right after the enter key was pressed instead of remaining in the center.   It appears that Excel is not updating the format of the cells when the format changes.

 

 

Thanks for your help!  

 

 

Ed.

0 Kudos
Message 5 of 6
(4,177 Views)

Hey lclutchl, 

 

Sorry you are having this problem! It seems to be fairly common with the use of the Excel Get Data vi. The example code posted on this Better Get Excel Data  discussion forum illustrates another way to get data from a spreadsheet. It does not deal with all of the inherent Excel formatting (which is probably causing your troubles), and instead just pulls a string from each cell. I know it looks scary, but you can just make this a subvi in your overall function, and it will work the way you expect. Hope this helps!

 

Cheers,

kgarrett 

District Sales Engineer
Message 6 of 6
(4,162 Views)