intToChar.tcl

 # input a number : 1 to 32 , you will get a char A to Z
#A-Z:1-32
proc intToChar {int} {
if {![string is integer $int]} {
return "Please input a number!"
}
if {![expr 0<$int&&32>$int]} {
return "Input a numer range 1 to 32!"
}
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]
} #test
#return [intToChar 1] intToChar.tcl 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 of the file !}
# }
if {""==$date} {
return "The date is NULL or '' !"
}
# set fileName {D:/test.xlsx}
# 创建com实例,打开工作表
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 "Sheet1"]
set worksheet [$worksheets Item [expr 1]]
set cells [$worksheet Cells] set exeFlag 1 if {1==$exeFlag} {
# set date {}
set dateRawLength [llength $date]
set rawIndex 0
while { $rawIndex < $dateRawLength } {
set dateColumnLength 0
set dateColumnLength [llength [lindex $date $rawIndex]]
set columnIndex 0
while { $columnIndex < $dateColumnLength } {
[$cells Item [expr $rawIndex+1] [intToChar [expr $columnIndex+1]]] Value2 [lindex [lindex $date $rawIndex] $columnIndex]
incr columnIndex
}
incr rawIndex
}
}
#code not work like wanting
# if {[regexp -all {\\|/} $fileName]} {
# cd [file dirname $fileName]
# }
#save without asking
$application DisplayAlerts [expr 0]
# $workbook SaveCopyAs {d://ts.xlsx}
$workbook SaveAs $fileName
$workbook Close
$application Quit
# return [file join [file dirname $fileName] [file tail $fileName]]
}
#含路径的文件保存时,有时会失败,原因不详(xls默认保存路径:菜单"文件"-->"选项"-->"保存",查看路径)
set fileName {d:\testaaa.xlsx}
set date [list [list 1 2 3 4 5 6 7 8 9 10] [list a b c d e f g] [list nihao hello 你好 howAreYou?]]
#test
return [xls_write $fileName $date]

最新文章

  1. 史上最全的maven的pom.xml文件详解
  2. Bootstrap 模态框(Modal)插件
  3. .net学习之进程外Session的配置
  4. H - Solve this interesting problem 分类: 比赛 2015-07-29 21:06 15人阅读 评论(0) 收藏
  5. google maps v3 添加自定义图标(marker,overlay)
  6. hdu 4104
  7. 锋利的Jquery解惑系列(三)------ 各路选择器大聚会
  8. scrapy1.1入门用例简介-2
  9. easyui treeJson 带层数
  10. JavaScript数组对象常用方法
  11. Python中time模块详解(转)
  12. Flume架构以及应用介绍
  13. IntelliJ IDEA 常用设置 (二)
  14. Linux Kafka集群管理工具kafka-manager的安装使用
  15. 传统餐饮O2O支付体系成难题
  16. Python中参数多个值的表示法
  17. html标签种类
  18. jsp的运行内幕--Tomcat容器对自定义标签的解析过程
  19. luogu4172 [WC2006]水管局长
  20. 【安装关键】webStorm-201703版本

热门文章

  1. linux终端terminal个性化配置(转)
  2. windows7内核驱动开发试验环境配置
  3. IOS低版本遇到了坑不知道你遇到了没
  4. Codeforces Round #384 (Div. 2) //复习状压... 罚时爆炸 BOOM _DONE
  5. 需要一个策略文件,但在加载此媒体时未设置checkPolicyFile标志
  6. AutoCad2008 部分快捷键
  7. sql一对多的两个表的update
  8. HR开发 读取员工工资
  9. .NET技术大系概览 (迄今为止最全的.NET技术栈)
  10. android studio怎么分享项目到Git@OSC托管