Hi,
I've made some progress on importing data from Excel files, in particular, finding "usedRange" came in very handy. However this gives me an IDispatch - range object, and that in turn gives me a (twodimensional) SAFEARRAY object. Everything fine up to that point. Cause I haven't figured out yet how to get deeper into that SAFEARRAY and retrieve the "rows", so that I can split them into individual records. How would I do that? Günther BTW the binary selector problem is resolved, naturaly I can't use '.' and I reckon neither can I use ';' for that matter. |
Hi Günther,
I'm curios about getting data directly from excel files. Could you post a example of it? thank you, Sebastian "Günther Schmidt" <[hidden email]> escribió en el mensaje news:[hidden email]... > Hi, > > I've made some progress on importing data from Excel files, in particular, > finding "usedRange" came in very handy. > > However this gives me an IDispatch - range object, and that in turn gives > me a (twodimensional) SAFEARRAY object. > > Everything fine up to that point. > > Cause I haven't figured out yet how to get deeper into that SAFEARRAY and > retrieve the "rows", so that I can split them into individual records. > > How would I do that? > > Günther > > > BTW the binary selector problem is resolved, naturaly I can't use '.' and > I reckon neither can I use ';' for that matter. |
In reply to this post by Günther Schmidt
No need to answer, got it figured out:
elementAt: (Array with: .... ) Günther Schmidt schrieb: > Hi, > > I've made some progress on importing data from Excel files, in > particular, finding "usedRange" came in very handy. > > However this gives me an IDispatch - range object, and that in turn > gives me a (twodimensional) SAFEARRAY object. > > Everything fine up to that point. > > Cause I haven't figured out yet how to get deeper into that SAFEARRAY > and retrieve the "rows", so that I can split them into individual records. > > How would I do that? > > Günther > > > BTW the binary selector problem is resolved, naturaly I can't use '.' > and I reckon neither can I use ';' for that matter. |
In reply to this post by Sebastián Sastre
Dear Sebastion.
you can have the ActiveXWizard create a package on Excel for you and then run this: file := FileOpenDialog showModal. excelApp1 := Excel_Application new. workbooks := excelApp1 workbooks. workbook := workbooks open: file lcid:0. "Don't know what lcid:0 is good for, but required" activeSheet := workbook activeSheet. usedRange := activeSheet usedRange "Returns an IDispatch of the actually used range on this sheet". array1 := usedRange value. "Returns a 2 dimensional SAFEARRAY" rows := array1 upperBound: 1. "Returns the upperBound of the 1st array dimension, ie. the number of rows" columns := array1 upperBound: 2. "Returns the upperBound of the 2nd array dimension, ie. the number of columns" results := OrderedCollection new. (1 to: rows) do: [:row | | resultRow| resultRow := OrderedCollection new. (1 to: columns) do:[ :column | |cell | cell := array1 elementAt: (Array with: row with: column) "Returns a VARIANT object which can be converted into a Smalltalk 'primitive' object by sending it #value". resultRow add: cell]. results add: resultRow]. results inspect. Hope it helps Günther Sebastián Sastre schrieb: > Hi Günther, > > I'm curios about getting data directly from excel files. Could you post > a example of it? > > thank you, > > Sebastian > > > "Günther Schmidt" <[hidden email]> escribió en el mensaje > news:[hidden email]... > >>Hi, >> >>I've made some progress on importing data from Excel files, in particular, >>finding "usedRange" came in very handy. >> >>However this gives me an IDispatch - range object, and that in turn gives >>me a (twodimensional) SAFEARRAY object. >> >>Everything fine up to that point. >> >>Cause I haven't figured out yet how to get deeper into that SAFEARRAY and >>retrieve the "rows", so that I can split them into individual records. >> >>How would I do that? >> >>Günther >> >> >>BTW the binary selector problem is resolved, naturaly I can't use '.' and >>I reckon neither can I use ';' for that matter. > > > |
Dear Günther,
It worked flawless. Very nice. I'm sure it could be useful thank you, Seb "Günther Schmidt" <[hidden email]> escribió en el mensaje news:[hidden email]... > Dear Sebastion. > > you can have the ActiveXWizard create a package on Excel for you and then > run this: > > file := FileOpenDialog showModal. > > > excelApp1 := Excel_Application new. > > workbooks := excelApp1 workbooks. > > workbook := workbooks open: file lcid:0. "Don't know what lcid:0 is good > for, but required" > > activeSheet := workbook activeSheet. > > usedRange := activeSheet usedRange "Returns an IDispatch of the actually > used range on this sheet". > > array1 := usedRange value. "Returns a 2 dimensional SAFEARRAY" > > rows := array1 upperBound: 1. "Returns the upperBound of the 1st array > dimension, ie. the number of rows" > > columns := array1 upperBound: 2. "Returns the upperBound of the 2nd array > dimension, ie. the number of columns" > > results := OrderedCollection new. > > (1 to: rows) do: [:row | | resultRow| > resultRow := OrderedCollection new. > > (1 to: columns) do:[ :column | |cell | cell := array1 elementAt: (Array > with: row with: column) "Returns a VARIANT object which can be converted > into a Smalltalk 'primitive' object by sending it #value". resultRow add: > cell]. > > results add: resultRow]. > > results inspect. > > > > Hope it helps > > Günther > > > > > Sebastián Sastre schrieb: >> Hi Günther, >> >> I'm curios about getting data directly from excel files. Could you >> post a example of it? >> >> thank you, >> >> Sebastian >> >> >> "Günther Schmidt" <[hidden email]> escribió en el mensaje >> news:[hidden email]... >> >>>Hi, >>> >>>I've made some progress on importing data from Excel files, in >>>particular, finding "usedRange" came in very handy. >>> >>>However this gives me an IDispatch - range object, and that in turn gives >>>me a (twodimensional) SAFEARRAY object. >>> >>>Everything fine up to that point. >>> >>>Cause I haven't figured out yet how to get deeper into that SAFEARRAY and >>>retrieve the "rows", so that I can split them into individual records. >>> >>>How would I do that? >>> >>>Günther >>> >>> >>>BTW the binary selector problem is resolved, naturaly I can't use '.' and >>>I reckon neither can I use ';' for that matter. >> >> |
Dear Sebastian,
there are a few things that keep giving me trouble with Excel, and that is when the Excel Application shuts down, it asks about whether or not to save the changes in the opened spreadsheets. Do you know of a setting which will turn this prompting off? I've seen some things like "rejectAllChanges" but that doesn't seem to work. Günther Sebastián Sastre schrieb: > Dear Günther, > > It worked flawless. Very nice. I'm sure it could be useful > > thank you, > > Seb > > > "Günther Schmidt" <[hidden email]> escribió en el mensaje > news:[hidden email]... > >>Dear Sebastion. >> >>you can have the ActiveXWizard create a package on Excel for you and then >>run this: >> >>file := FileOpenDialog showModal. >> >> >>excelApp1 := Excel_Application new. >> >>workbooks := excelApp1 workbooks. >> >>workbook := workbooks open: file lcid:0. "Don't know what lcid:0 is good >>for, but required" >> >>activeSheet := workbook activeSheet. >> >>usedRange := activeSheet usedRange "Returns an IDispatch of the actually >>used range on this sheet". >> >>array1 := usedRange value. "Returns a 2 dimensional SAFEARRAY" >> >>rows := array1 upperBound: 1. "Returns the upperBound of the 1st array >>dimension, ie. the number of rows" >> >>columns := array1 upperBound: 2. "Returns the upperBound of the 2nd array >>dimension, ie. the number of columns" >> >>results := OrderedCollection new. >> >>(1 to: rows) do: [:row | | resultRow| >>resultRow := OrderedCollection new. >> >>(1 to: columns) do:[ :column | |cell | cell := array1 elementAt: (Array >>with: row with: column) "Returns a VARIANT object which can be converted >>into a Smalltalk 'primitive' object by sending it #value". resultRow add: >>cell]. >> >>results add: resultRow]. >> >>results inspect. >> >> >> >>Hope it helps >> >>Günther >> >> >> >> >>Sebastián Sastre schrieb: >> >>>Hi Günther, >>> >>> I'm curios about getting data directly from excel files. Could you >>>post a example of it? >>> >>> thank you, >>> >>>Sebastian >>> >>> >>>"Günther Schmidt" <[hidden email]> escribió en el mensaje >>>news:[hidden email]... >>> >>> >>>>Hi, >>>> >>>>I've made some progress on importing data from Excel files, in >>>>particular, finding "usedRange" came in very handy. >>>> >>>>However this gives me an IDispatch - range object, and that in turn gives >>>>me a (twodimensional) SAFEARRAY object. >>>> >>>>Everything fine up to that point. >>>> >>>>Cause I haven't figured out yet how to get deeper into that SAFEARRAY and >>>>retrieve the "rows", so that I can split them into individual records. >>>> >>>>How would I do that? >>>> >>>>Günther >>>> >>>> >>>>BTW the binary selector problem is resolved, naturaly I can't use '.' and >>>>I reckon neither can I use ';' for that matter. >>> >>> > |
Günther,
> there are a few things that keep giving me trouble with Excel, and that > is when the Excel Application shuts down, it asks about whether or not > to save the changes in the opened spreadsheets. > > Do you know of a setting which will turn this prompting off? > I've seen some things like "rejectAllChanges" but that doesn't seem to > work. At least with Word, there is an optional argument to Quit() - look at my Word Automation package (WordAutomation>>stop), and better yet, VBA for Dummies for details. Have a good one, Bill -- Wilhelm K. Schwab, Ph.D. [hidden email] |
Free forum by Nabble | Edit this page |