Chinaunix首页 | 论坛 | 博客
  • 博客访问: 182458
  • 博文数量: 42
  • 博客积分: 2235
  • 博客等级: 大尉
  • 技术积分: 460
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-15 20:17
文章分类

全部博文(42)

文章存档

2012年(1)

2011年(7)

2010年(33)

2009年(1)

我的朋友

分类:

2010-06-06 21:05:02

#latest tcl
#install tcom package using teacup.
#how to use teacup
set docname "h:/ACG_FamilyCom_STD_Router_v0.1.doc"
set tmpname "h:/tmp.doc"

package require tcom
set application [::tcom::ref createobject "Word.Application"]
$application Visible 1
set H_Documents [$application Documents]
set Document [$H_Documents Open $docname]
set Tables [$Document Tables]
#set fid [open h:\ACG_FamilyCom_STD_Router_v0.1.html w]
for {set i 1} {$i<=[$Tables Count]} {incr i} {
   set nowtable [$Tables Item $i]
   set Rows [$nowtable Rows]
   set Columns [$nowtable Columns]
   puts $i:[$Rows Count]:[$Columns Count]
   set Cell [$nowtable Cell 1 1]
   set Range [$Cell Range]
   regsub -all {[^a-zA-Z0-9 _]} [$Range Text] {} text
   set text [$Range Text]
   if {![regexp {Test Case} $text]} {
       continue
   }
   for {set row 1} {$row<=[$Rows Count]} {incr row} {
       for {set col 1} {$col<=[$Columns Count]} {incr col} {
           set Cell [$nowtable Cell $row $col]
           set Range [$Cell Range]
           regsub -all {[^[:punct:][:space:][:alnum:]]} [$Range Text] {} text
           if {[string length $text] >0} {
               set text [string range $text 0 end-1]
           }
           if {$col == 1} {
               set testcase $text  
           }
           if {$col == 2} {
               set description $text  
           }
           if {$col == 3} {  
               set assumption $text
           }
           if {$col == 4} {  
               set actions $text
           }
           if {$col == 5} {  
               set expected $text
           }
       }
       lappend fulllist $testcase $description $assumption $actions $expected
   }
}
#close $fid
$application Quit

set application [::tcom::ref createobject "Word.Application"]
$application Visible 1
set H_Documents [$application Documents]
set Document [$H_Documents Open $tmpname]
set Tables [$Document Tables]
set i 3
foreach {testcase description assumption actions expected} $fulllist {
   #puts "$testcase $description $assumption $actions $expected"
   puts "$i"
   set nowtable [$Tables Item $i]
   set Rows [$nowtable Rows]
   set Columns [$nowtable Columns]
   set Cell [$nowtable Cell 1 2];set Range [$Cell Range];
   $Range Text $testcase
   set Cell [$nowtable Cell 2 2];set Range [$Cell Range];
   $Range Text $description
   set Cell [$nowtable Cell 5 2];set Range [$Cell Range];
   $Range Text $assumption
   set Cell [$nowtable Cell 6 2];set Range [$Cell Range];
   $Range Text $actions
   set Cell [$nowtable Cell 7 2];set Range [$Cell Range];
   $Range Text $expected
   incr i
}

proc methods H_interface {
   set int [::tcom::info interface $H_interface]
   foreach x [$int methods] {
       lappend a "[lindex $x 2] [lindex $x 0] [lindex $x 1] [lindex $x 3]"
   }
  
   foreach x [lsort $a] {
       puts $x
   }
}
阅读(2580) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~