0

我有一个 powershell 脚本,可以写入 word 文档中的一个大表,但速度很慢。我想知道是否有一种方法可以加快速度,或者是否有更有效的方法来做到这一点。我只写到表格的最后一行

$wd = New-Object -ComObject Word.Application
$wd.Visible = $false
$doc = $wd.Documents.Open("test.doc"  )
$iTable = $doc.Tables.Item(1)
$r = $iTable.Rows.Count
$c = 1

#write to doc
$iTable.Cell($r, $c).Range.Text=$int
$iTable.Cell($r, $c+1).Range.Text=(get-item env:$x).Value
$iTable.Cell($r, $c+2).Range.Text=$lob.ToUpper()
$iTable.Cell($r, $c+3).Range.Text=$line
4

0 回答 0