Question

Using the Excel COM automation interface I can set value in a cell by doing:

excel := COMDispatchDriver createObject: 'Excel.Application'.
excel getWorkbooks Add. 
excel setVisible: true.
(excel getRange: 'A1') setValue: 100

Is there a way I can do this with a collection, something like:

excel := COMDispatchDriver createObject: 'Excel.Application'.
excel getWorkbooks Add. 
excel setVisible: true.
(excel getRange: 'A1:A4') setValue: #(1 2 3 4)
Was it helpful?

Solution

ExcelApplicationController

| cont |
cont := (Examples.Excel97ApplicationController new).
[
  cont addWorkbook.
  cont isVisible: true.

  "Insert the title of our report."
  cont caption: 'First Quarter Results'.

  cont setRange: 'B5:E9'
     to: #( #( 10 20 30 40 ) #( 1 2 3 4 ) #( 101 201 301 401) #( 102 203 305 407 ) ).


] ensure:[
  cont notNil
        ifTrue: [
            cont release.
            cont := nil ]
]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top