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

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

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



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

本帖子中包含更多资源

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

×
发表于 2014-5-28 13:03:57 | 显示全部楼层
[au3]
#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)
[/au3]
发表于 2014-5-28 18:05:46 | 显示全部楼层
  1. #include <array.au3>
  2. $doc=ObjGet(@ScriptDir&"\word源文件.doc")
  3. If IsObj($doc) Then
  4.         If $doc.tables.count>0 Then
  5.                 For $tbl In $doc.tables
  6.                         With $tbl
  7.                                 Dim $arr[.rows.count][.columns.count]
  8.                                 For $cell In .range.cells
  9.                                         $arr[$cell.rowindex-1][$cell.columnindex-1]=StringTrimRight($cell.range.text,2)
  10.                                 Next
  11.                                 _ArrayDisplay($arr)
  12.                                 ConsoleWrite(UBound($arr)&@TAB&UBound($arr,2)&@CRLF)
  13.                                 For $n=1 To UBound($arr)-1
  14.                                         For $i=0 To UBound($arr,2)-1
  15.                                                 If StringLen($arr[$n][$i])=0 Then $arr[$n][$i]=$arr[$n-1][$i]
  16.                                         Next
  17.                                 Next
  18.                                 _ArrayDisplay($arr)
  19.                         EndWith
  20.                 Next
  21.         EndIf
  22.         $doc.saved=True
  23.         $doc.close
  24. EndIf
复制代码
单纯的同列单元格合并可以试下,复杂的不行
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2026-9-22 09:51 , Processed in 0.069281 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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