找回密码
 加入
搜索
查看: 2237|回复: 2

[效率算法] 如何把Word合并单元格拆分成合并前的状态,并填充拆分后的单元格内容。

[复制链接]
发表于 2014-5-28 11:16:30 | 显示全部楼层 |阅读模式



看图就明白了。先感谢各位大神。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-5-28 13:03:57 | 显示全部楼层

#include <Word.au3>

Local $oWordApp = _Word_Create("")
Local $oDoc = _Word_DocOpen($oWordApp, @ScriptDir & "\Test.doc", 1)

MsgBox(0, '', '点击确定插入表格')
$oDoc.Tables.Add($oDoc.Range,3, 5, 1, 0)
MsgBox(0, '', '点击确定分割表格')
$oDoc.Tables(1).Cell(1,1).Split(2, 1)

_Word_DocClose($oDoc)
_Word_Quit($oDoc, 0)
发表于 2014-5-28 18:05:46 | 显示全部楼层
#include <array.au3>
$doc=ObjGet(@ScriptDir&"\word源文件.doc")
If IsObj($doc) Then
        If $doc.tables.count>0 Then
                For $tbl In $doc.tables
                        With $tbl
                                Dim $arr[.rows.count][.columns.count]
                                For $cell In .range.cells
                                        $arr[$cell.rowindex-1][$cell.columnindex-1]=StringTrimRight($cell.range.text,2)
                                Next
                                _ArrayDisplay($arr)
                                ConsoleWrite(UBound($arr)&@TAB&UBound($arr,2)&@CRLF)
                                For $n=1 To UBound($arr)-1
                                        For $i=0 To UBound($arr,2)-1
                                                If StringLen($arr[$n][$i])=0 Then $arr[$n][$i]=$arr[$n-1][$i]
                                        Next
                                Next
                                _ArrayDisplay($arr)
                        EndWith
                Next
        EndIf
        $doc.saved=True
        $doc.close
EndIf
单纯的同列单元格合并可以试下,复杂的不行
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-6 08:15 , Processed in 0.081951 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表