是否有人能够帮助我这个脚本。
$file = 'C:\Scripts\Spreadsheet.xlsx'
$x1 = New-Object -ComObject "Excel.Application"
$x1.Visible = $false
$enddate = (Get-Date).tostring("dd-MM-yy")
$filename = 'C:\Scripts\Spreadsheet ' + $enddate + '.xlsx'
$wb = $x1.workbooks.Open($file)
$wb.refreshall
$wb.SaveAs($filename)
$wb.Close()
$x1.Quit()
Remove-Variable wb,x1
工作簿将通过ODBC连接打开并使用外部数据更新其数据透视表。手动打开工作簿时,它会刷新。当您使用脚本打开它时,它只会打开并且不会刷新数据。
我尝试过以下方法:
任何帮助将不胜感激,谢谢!
更改
$wb.RefreshAll
至
$wb.RefreshAll()