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 rows [array size atten]
for {set row 1} {$row <= $rows} {incr row} {
$cells Item $row "B" $atten($row)
}
$workbook SaveAs Filename {c:\tst.csv}
$application Quit
Hi.I’m able to write the data in CSV format. But the data is all corrupted. For example, when i opened it with notepad the data is corrupted, I mean i don’t see the data seperated by comma. Is there any problem with the method that i use to write the data to CSV format??
Having the file name end in
.csvisn’t enough to tell Excel to save as CSV. You have to pass a file type constant to theSaveAsmethod. Not sure about Tcl syntax, but I’m guessing the correct invocation ofSaveAswould beSaveAs documentation