My handle is PataElmo. I'm working on making fun and interesting things in TCL. Firstly trying to build a base of good classes in iTCL.
I have some interesting code for handling Excel through the tcom interface. This little proc allows you to control excel close to how you would in VB.
proc ExcelCmd {App command} {
set clist [split [regsub -all {\(([^()]+)\)} $command { \1}] .]
set string $App
while {[llength $clist]>0} {
if {[llength [lindex $clist 0]]>1} {
if {[expr {! [catch {expr {int([lindex [lindex $clist 0] 1])}}]}]} {
set string [$string [lindex [lindex $clist 0] 0] [expr [lindex [lindex $clist 0] 1]]]
} else {
set string [$string [lindex [lindex $clist 0] 0] [lindex [lindex $clist 0] 1]]
}
} else {
set string [$string [lindex $clist 0]]
}
set clist [lreplace $clist 0 0]
}
return $string
}Usage:
set App [::tcom::ref createobject Excel.Application]
ExcelCmd $App Visible(0)
ExcelCmd $App Workbooks.Add
ExcelCmd $App Workbooks.Item(1).Worksheets.Item(2).Delete
ExcelCmd $App Workbooks.Item(1).Worksheets.Item(2).Delete
ExcelCmd $App Workbooks.Item(1).Worksheets.Item(1).Name("First")
ExcelCmd $App Visible(1)