Excel operations using tcl

1.Install ActiveTcl 8.5

2.run the command to work with excel

teacup install tcom

#1.How to create an excel and write data to that excel and save it using tcl

#The below example explains how to write "india" in 3 rd row and A column

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]

# write data to excel at 3 rd row A coloumn

$cells Item 3 A "india"

# read data from excel from 3rd row A coloumn

set str [[$cells Item 3 A] -get Value]

puts $str

#set i 0

#foreach row {1 2 3} {

# foreach column {A B C} {

# $cells Item $row $column [incr i]

# }

#}

$workbook SaveAs {c:\sample.xls}

$application Quit