1 INTTOCHAR.TCL2 3 #input a number:1 to +, you'll get a char a to Z4 #a-z:1-325 proc Inttochar {int} {6 if{! [String isinteger $int]} {7 return "Please input a number!"8 } 9 if{! [Expr 0< $int &&32>$int]} {Ten return "Input a numer range 1 to 32!" One } A set listchars [list A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] -Set intTemp [Expr $int-1] - return[lindex $listChars $intTemp] the } - - #Test - #return [Inttochar 1] + - + INTTOCHAR.TCL A at Package require tcom - Source INTTOCHAR.TCL - proc Xls_write {fileName date} { - #if {[File exists $fileName]} { - #return {File is existed! Please delete or change the the the the file!} - # } in if{""==$date} { - return "The date is NULL or '!" to } + #set FileName {d:/test.xlsx} - #Create a COM instance, open a worksheet theSet application [:: Tcom::ref CreateObject"Excel.Application"] *$application Visible 1 $ set workbooks [$application workbooks]Panax Notoginseng Set workbook [$workbooks Add] - set worksheets [$workbook worksheets] the #set worksheet [$worksheets Item "Sheet1"] +set worksheet [$worksheets Item [Expr 1]] A set cells [$worksheet cells] the +Set Exeflag 1 - $ if{1==$exeFlag} { $ #set Date {} - set daterawlength [llength $date] - Set Rawindex 0 the while{$rawIndex <$dateRawLength} { - Set Datecolumnlength 0Wuyi set datecolumnlength [llength [lindex $date $rawIndex]] the Set ColumnIndex 0 - while{$columnIndex <$dateColumnLength} { Wu[$cells Item [Expr $rawIndex +1] [Inttochar [Expr $columnIndex +1]] Value2 [lindex [lindex $date $rawIndex] $columnIndex] - incr columnindex About } $ incr Rawindex - } - } - #code not work like wanting A #if {[Regexp-all {\\|/} $fileName]} { + #CD [File DirName $fileName] the # } - #Save without asking $ $application DisplayAlerts [expr 0] the #$workbook SaveCopyAs {d://ts.xlsx} the $workbook SaveAs $fileName the $workbook Close the $application Quit - #return [file join [File dirname $fileName] [file tail $fileName]] in } the #when a file with a path is saved, it sometimes fails for an unknown reason (xls default save path: Menu "File"--"options"-"save", view path) the set FileName {d:\testaaa.xlsx} AboutSet date [list [List 1 2 3 4 5 6 7 8 9 10] [List A b c D e F g] [list Nihao hello hello howareyou? ]] the #Test the return[Xls_write $fileName $date]
TCL: Write Data in table (XLS)