#130771 - 2004-12-07 07:21 PM
Parsing information from an excel document
|
Josh_R
Getting the hang of it
Registered: 2003-11-25
Posts: 54
|
I am trying to figure out a way to parse information from an excel document. I have searched through the site and can't find anything that is at my level of scripting (novice). Can any one out there help me?
|
|
Top
|
|
|
|
#130773 - 2004-12-07 08:00 PM
Re: Parsing information from an excel document
|
Josh_R
Getting the hang of it
Registered: 2003-11-25
Posts: 54
|
It is an actual XLS document. Yes the computer has excel installed on it. By parse I mean take out certain information (user names) from a column.
|
|
Top
|
|
|
|
#130775 - 2004-12-07 08:35 PM
Re: Parsing information from an excel document
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Quote:
my level of scripting (novice).
Josh,
Unless one of the more advanced scripters here takes it on for you the answer is no. There is no easy built-in method with probably any script language. Can it be done, yes it can be done, but it is not a novice level task.
If someone does decide to help you completely with this task then you will need to be more specific on all the details and show examples. Les asked you a few questions and you only maybe answered one or two.
Please provide all the details asked, also the version of KiXtart you're using.
Will it be done locally on your system or some other system, does it need to be done remotely? What version of Excel?
Please show examples of what is in the columns and what you want removed, etc...
|
|
Top
|
|
|
|
#130776 - 2004-12-08 10:26 AM
Re: Parsing information from an excel document
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
As the boys have said earlier, the process is not simple.
This example is as simple as I could make it, it returns the values in column "A" of the active worksheet in workbook "c:\temp\demo.xls"
This demo assumes that the first empty cell is the end of the list (otherwise *all* possible cells in column A are returned).
Code:
Break ON $sMyDocument="C:\temp\demo.xls" ; Create Excel application $oExcel=CreateObject("Excel.Application") ; Uncomment the next line to make it visible ; $oExcel.Visible = 1 ; Load the demo document $oWorkbook=$oExcel.Workbooks.Open($sMyDocument) ; Get the active worksheet $oWorksheet=$oWorkbook.ActiveSheet ; Iterate the cells in column A, stopping on the first blank cell For Each $oCell in $oWorksheet.Columns("A:A").Cells $iCounter=$iCounter+1 $sText=$oCell.Text If $sText="" Goto "CellLoopDone" EndIf $iCounter " " $sText ? Next :CellLoopDone ; Clean up $oExcel.Quit() $oExcel=0 Exit 0
If anyone can think of a nicer way to break out of the collection iteration I'd be interested.
|
|
Top
|
|
|
|
#130782 - 2004-12-08 02:48 PM
Re: Parsing information from an excel document
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
What happened to READEXCEL() or READEXCEL2() UDFs?
Kent
|
|
Top
|
|
|
|
#130784 - 2004-12-08 03:02 PM
Re: Parsing information from an excel document
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
A simple example is fine.. I guess we have always tried to direct folks over to the UDF section rather than re-invent the wheel..
Kent
|
|
Top
|
|
|
|
#130786 - 2004-12-08 03:54 PM
Re: Parsing information from an excel document
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Nicer means without GOTO ?
Yup. I want to keep the FOR EACH, but avoid the GOTO.
|
|
Top
|
|
|
|
#130788 - 2004-12-08 05:13 PM
Re: Parsing information from an excel document
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
so my code was just fine. 
Yes and No 
There is nothing wrong with your code per se, however you switched to a FOR..TO - I specifically wanted to keep the collection enumeration (FOR...EACH...IN).
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1471 anonymous users online.
|
|
|