不定期日記
J2千葉観戦記, ライブの感想を中心とした備忘録
2003-05-08 (Thu) [長年日記]
_ VisualWorks 5i.2
$(VISUALWORKS)\com\COM-ALL.pcl を Parcel in する必要があります。
VBScript と全く同じ流れです。
example1 "Open Excel Window"
| controller workbook worksheet | controller := COMAutomationApplicationController on: (COMAutomationApplicationController dispatchDriverClass createObject: (GUID clsidFromProgID: 'Excel.Application')). controller isVisible: true. workbook := (controller getProperty: 'Workbooks') getProperty: 'Add'. worksheet := workbook getProperty: 'Worksheets' with: 1. worksheet setProperty: 'Range' withArguments: (Array with: 'A1:D1' with: (Array with: 'North' with: 'South' with: 'East' with: 'West')). ^controller
Excel用のクラスが用意されていたのでそれを利用しました。
example2 "Open Excel Window"
| controller worksheet | controller := Examples.Excel97ApplicationController new. controller isVisible: true. controller addWorkbook. worksheet := controller worksheets at: 1. worksheet setRange: 'A1:D1' to: (Array with: 'North' with: 'South' with: 'East' with: 'West'). ^controller
_ VBScript
拡張子を .vbs にして保存し、ダブルクリックすると実行できます。
Option Explicit Dim excel, workbook, worksheet Set excel = WScript.CreateObject("Excel.Application") excel.Visible = True Set workbook = excel.Workbooks.Add() Set worksheet = workbook.Worksheets(1) worksheet.Range("A1:D1").value = Array("North", "South", "East", "West")
_ ActiveScriptRuby
参考: COM Meets Ruby, Win32OLE製作過程の雑記
require 'win32ole'
excel = WIN32OLE.new('Excel.Application') excel.visible = TRUE workbook = excel.Workbooks.Add(); worksheet = workbook.Worksheets(1); worksheet.Range('A1:D1').value = ['North', 'South', 'East', 'West'];
2020|07|