Comment puis-je utiliser les collections avec l'interface com Excel à partir d'œuvres visuelles

StackOverflow https://stackoverflow.com/questions/4670136

  •  10-10-2019
  •  | 
  •  

Question

En utilisant la valeur interface d'automatisation COM Excel je peux mettre dans une cellule en faisant:

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

Est-il possible que je peux le faire avec une collection, quelque chose comme:

excel := COMDispatchDriver createObject: 'Excel.Application'.
excel getWorkbooks Add. 
excel setVisible: true.
(excel getRange: 'A1:A4') setValue: #(1 2 3 4)
Était-ce utile?

La 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 ]
]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top