Page 1 of 1 1
Topic Options
#174667 - 2007-03-14 01:11 PM Excel cell values return blank for numbers
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
I am trying to read information from an Excel spreadsheet.

I can read text values ok with:-
$c = $oXL.cells(1,1).value
But numerical data returns nothing.
I can set numerical data with:-

$oXL.cells(2,2).value = 12.34
But can't read it.

Am I doing something fundamentally wrong?

I've tried with KiXtart versions 4.20 & 4.53

Thanks

Bill
_________________________
Bill

Top
#174668 - 2007-03-14 02:08 PM Re: Excel cell values return blank for numbers [Re: BillBarnard]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
You might try using the ReadExcel2() UDF as a sanity test.

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84265&page=1#Post84265
_________________________
(... better days ahead)

Top
#174669 - 2007-03-14 02:29 PM Re: Excel cell values return blank for numbers [Re: Allen]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Thanks for the reply.
ReadExcel2 was what I started with before I generated my own script.
I have sorted it now.
A variable didn't resolve properly in a display string.

i.e. The first $c displays OK, the one inside the string doesn't unless itself is a string value. Whereas the $Row and $Col do. Is this a bug?

For $Row = 1 to 3
For $Col = 1 to 3
$c = $oXL.cells($Row,$Col).value
$c ?
"$Row : $Col = $c" ?
Next
Next

Cheers,
Bill


Edited by BillBarnard (2007-03-14 02:38 PM)
_________________________
Bill

Top
#174681 - 2007-03-14 05:38 PM Re: Excel cell values return blank for numbers [Re: BillBarnard]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Two things...

Fix your code so that that there are no var in strings, ie.
this
"$Row : $Col = $c" ?
should be this
$Row + " : " + $Col + " = " + $c

You should also consider adding $RC=SetOption("NoVarsInStrings","on") to the top of all your scripts to enforce this.

Second, what is happening is not a bug but simply how kixtart handles data types. $Row and $Col are numbers, and $c is sometimes a number and sometimes text.
To fix this try:
"" + $Row + " : " + $Col + " = " + $c
_________________________
(... better days ahead)

Top
#174694 - 2007-03-15 01:33 PM Re: Excel cell values return blank for numbers [Re: Allen]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Thanks again.

It's basically down to the fact that KiXtart cannot resolve Double Precision variables inside strings.

$c = 1
"Hello $c" ?

Resolves

$c = cdbl($c)
"Hello $c" ?

Doesn't resolve

The manual only says it can't resolve arrays & object references inside strings. Never mind, that's life.

Best Regards,
Bill
_________________________
Bill

Top
#174696 - 2007-03-15 01:52 PM Re: Excel cell values return blank for numbers [Re: BillBarnard]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
 Quote:
The manual only says it can't resolve arrays & object references inside strings. Never mind, that's life.


HEY! When did people start reading the manual again. I thought selormquarshie had secured it firmly as his boat anchor. ;\)

Seriously though... what you found may be a bug, but I think you will find that most in the kixtart community will push for not having vars in strings. If it truly is a bug, at least the fix is simple. \:\)
_________________________
(... better days ahead)

Top
#174697 - 2007-03-15 01:59 PM Re: Excel cell values return blank for numbers [Re: Allen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I've just tested with versions 4.50 and 4.12 and they exhibit the same symptom, so it's been around a while.

I'd consider it the "don't use vars in strings" encouragement feature, rather than a bug ;\)

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 867 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.056 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org