# This example controls Excel. It performs the following steps. # - Start Excel application. # - Create a new workbook. # - Put values into some cells. # - Save the workbook to a file. # - Exit Excel application. package require tcom set application [::tcom::ref createobject "Excel.Application"] $application Visible 1 set workbooks [$application Workbooks] set workbook [$workbooks Add] set worksheets [$workbook Worksheets] set worksheet [$worksheets Item [expr 1]] set cells [$worksheet Cells] set i 0 foreach row {1 2 3} { foreach column {A B C} { $cells Item $row $column [incr i] } } $workbook SaveAs {c:\tst.xls} $application Quit