#44406 - 2003-08-21 04:52 PM
ReadExcel2 UDF
|
Wintermute
Fresh Scripter
Registered: 2003-05-13
Posts: 11
|
I am examining the use of this UDF to read information from a single cell (i.e. Row 5, Column 7) within a spreadsheet and assign it to a variable. Then I want to display the result in a KiXform.
I have noticed that the stated action of this function is to read values from Excel to a 2-dimensional array.
In testing it with KiXtart version 4.21 and windows 2000, I have been unable to get it pull a single value out of a spreadsheet and display it. Am I using the function in a manner other than what it was designed for?
I will post the code if I am using the function as intended. If I am not, can anyone suggest a function that will read a specific cell by coordinated in Excel? I examined the ReadExcel UDF, but I'm not sure from reading the description that it will perform what I need. Can anyone shed some light on the best UDF for my situation?
|
|
Top
|
|
|
|
#44407 - 2003-08-21 05:20 PM
Re: ReadExcel2 UDF
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Hi Winter, might try this little snippet. It reads a spreadsheet called TEST.XLS in the current script directory.
code:
break on
$excel = createobject("excel.application") $excel.visible = 0 $excel.displayalerts = 0
$book = $excel.workbooks.open("@SCRIPTDIR\TEST.XLS")
if $book
$value = $excel.activesheet.columns(7).rows(5).value
?"Value=" $value
endif
$excel.visible = 0 $excel.quit() $excel = 0
exit 1
|
|
Top
|
|
|
|
#44408 - 2003-08-21 05:36 PM
Re: ReadExcel2 UDF
|
Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
So, what doescode:
$value=READEXCEL2('file.xls', 1, 1, 1, 5, 7) ? ubound($value,1) ? ubound($value,2) ? $value[0,0]
give?
_________________________
There are two types of vessels, submarines and targets.
|
|
Top
|
|
|
|
#44409 - 2003-08-25 05:14 PM
Re: ReadExcel2 UDF
|
Wintermute
Fresh Scripter
Registered: 2003-05-13
Posts: 11
|
Thank-you Shawn! That is returning values to the console from the spreadsheet. The UDF ReadExcel2 was not, I suspect it is more suited to reading more than one cell.
Anyway, not a problem any longer as the code supplied works just fine.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1047 anonymous users online.
|
|
|