TCL:表格(xls)中写入数据
- 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]
TCL:表格(xls)中写入数据的更多相关文章
- python新建一个表格xls并写入数据
# -*- coding:utf-8 -*- import xlwt workbook = xlwt.Workbook() # 新建一个工作簿 sheet = workbook.add_sheet(& ...
- TCL:读取表格(xls)中的数据
intToChar.tcl # input a number : 1 to 32 , you will get a char A to Z #A-Z:1-32 proc intToChar {int} ...
- Python中如何读取xls中的数据
要想读取EXCEL中的数据,首先得下载xlrd包,地址:https://pypi.python.org/pypi/xlrd 安装方法:下载解压后,利用windows dos命令进入解压目录eg,c ...
- POI往word模板中写入数据
转: POI往word模板中写入数据 2018年03月24日 16:00:22 乄阿斗同學 阅读数:2977 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn ...
- 向post请求中写入数据,最终保存在了HttpWebRequest.Params中
一.向post请求中写入数据,最终保存在了HttpWebRequest.Params中: 1)如果存入的是IDictionary类型的字符串变量,如:“username=administrator”, ...
- PHP连接sqlserver的两种方法,向sqlserver2000中写入数据,中文乱码
项目环境是php5.3.28 项目用的ThinkPHP3.2.3 已经mysql5.5数据库,要和另一个项目对接,需要连接sqlsever2000数据库进行一些操作. 第一种用php自带扩展连接数据 ...
- 通过I2C总线向EEPROM中写入数据,记录开机次数
没买板子之前,用protues画过电路图,实现了通过i2c总线向EEPROM中写入和读出数据. 今天,在自己买的板子上面写关于i2c总线的程序,有个地方忘了延时,调程序的时候很蛋疼.下面说说我对I2c ...
- 【转】从QDataStream向QByteArray中写入数据时的注意点(QT)
最近发现从QDataStream向QByteArray中写入数据常常是写不进去的,通过查看QT的源码: QDataStream &operator>>(QDataStream &a ...
- Verilog利用$fdisplay命令往文件中写入数据
最近在做的事情是,用FPGA生成一些满足特定分布的序列.因此为了验证我生成的序列是否拥有预期的性质,我需要将生成的数据提取出来并且放到MATLAB中做数据分析. 但是网上的程序很乱,表示看不懂==其实 ...
随机推荐
- selenium—八种定位方法
find_element_by_id() find_element_by_name() find_element_by_class_name() find_element_by_tag_name() ...
- ffmpeg 音频转换: use ffmpeg convert the audio from stereo to mono without changing the video part
To convert the audio from stereo to mono without changing the video part, you can use FFmpeg: ffmpeg ...
- 关于iOS10 Xcode8真机测试项目出现的问题 "code signing is required for product type 'xxxxx' in SDK 'iOS 10.0"..
昨天用真机测试项目出现这样的错误,在网上搜集了一些信息,所以将自己的经验分享出来帮助更多的人. 第一步: 检查你的1和2是否填写正确,如果你是运行别人的项目,BundleIdentifier要和你的X ...
- deeplab hole algorithm
最近看了几篇文章,其中均用到了hole algorithm. 最早用的就是deeplab的文章了,Semantic Image Segmentation with Deep Convolutional ...
- css3 animation动画特效插件的巧用
这一个是css3 animation动画特效在线演示的网站 https://daneden.github.io/animate.css/ 下载 animate.css文件,文件的代码很多,不过要明白 ...
- 初涉定制linux系统之——自动化安装Centos系统镜像制作
最近碰到个需求:要在内网环境安装centos6.5系统并搭建服务,但由于自动部署脚本里安装依赖包使用的是yum安装,而服务器无法连接外网,实施人员也不会本地yum源搭建O__O "….. 本 ...
- 09-JAVA中的异常处理
1. 程序执行结果: 也就是它根本就没抛出异常,更别提捕获异常了.那么,为什么会这样呢? 原来, 如上面程序展示,程序运行到k=i/j;的时候,就会直接终止,根本就不会运行到监视的程序,更不会运行到捕 ...
- 拼图 canvas分割 dom拖拽 pc 移动端
参考:Canvas drag 实现拖拽拼图小游戏 参考的案例,不支持手机端.总结下实现过程中遇到的小坑. gitHub:https://github.com/WppFrontEnd/puzzle 大概 ...
- Zxing兼容2.3等低版本
需要修改的地方 1.InactivityTimer.java public synchronized void onActivity() { ... if (Build.VERSION.SDK_INT ...
- 有趣的代码: fixTypeof
typeof 可以匹配对象的类型,但是他的能力很弱,比如 typeof new String('123')会显示的object这是我们不想看到的结果很久以前JQ的作者通过Object.prototyp ...