2011-01-12 23 views
0

使用Excel的COM自動化接口,我可以在小區中設置值:我如何做使用與Excel的COM接口的集合,從視覺作品

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

有沒有一種方法,我可以用一個集合做到這一點,類似於:

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

回答

2
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 ] 
] 
相關問題