Come posso utilizzare le collezioni con l'interfaccia COM Excel da opere visive
-
10-10-2019 - |
Domanda
Utilizzando l'automazione di Excel COM interfaccia è possibile impostare il valore in una cella facendo:
excel := COMDispatchDriver createObject: 'Excel.Application'.
excel getWorkbooks Add.
excel setVisible: true.
(excel getRange: 'A1') setValue: 100
C'è un modo che io possa fare questo con una collezione, qualcosa come:
excel := COMDispatchDriver createObject: 'Excel.Application'.
excel getWorkbooks Add.
excel setVisible: true.
(excel getRange: 'A1:A4') setValue: #(1 2 3 4)
Soluzione
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 ]
]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow