代码拉取完成,页面将自动刷新
<Query Kind="VBStatements">
<Reference><ProgramFilesX86>\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll</Reference>
<Namespace>System.Collections.ObjectModel</Namespace>
<Namespace>System.Management.Automation</Namespace>
</Query>
Dim PowerShellInstance As PowerShell = PowerShell.Create
Dim scriptBuilder As New System.Text.StringBuilder
scriptBuilder.AppendLine("param($WorkbookFullPath)")
scriptBuilder.AppendLine("$ExcelApp = New-Object -ComObject Excel.Application")
scriptBuilder.AppendLine("$ExcelApp.DisplayAlerts = $false")
scriptBuilder.AppendLine("$ExcelWorkbook = $ExcelApp.Workbooks.Open($WorkbookFullPath)")
scriptBuilder.AppendLine("$ExcelWorksheet = $ExcelWorkbook.Worksheets.Item('PivotResult')")
scriptBuilder.AppendLine("$ExcelWorksheet.Activate()")
scriptBuilder.AppendLine("$PivotTable = $ExcelWorksheet.PivotTables('ncov')")
scriptBuilder.AppendLine("$PivotTable.ClearTable()")
scriptBuilder.AppendLine("Remove-Variable -Name PivotTable,ExcelWorksheet")
scriptBuilder.AppendLine("$ExcelWorkbook.Save()")
scriptBuilder.AppendLine("$ExcelWorkbook.Close($false)")
scriptBuilder.AppendLine("Remove-Variable -Name ExcelWorkbook")
scriptBuilder.AppendLine("$ExcelApp.Quit()")
scriptBuilder.AppendLine("Remove-Variable -Name ExcelApp")
scriptBuilder.AppendLine("Stop-Process -Name EXCEL")
PowerShellInstance.AddScript(scriptBuilder.ToString)
PowerShellInstance.AddParameter("WorkbookFullPath", "E:\Gitee\TestData03.xlsx")
Dim PSOutput As Collection(Of PSObject) = PowerShellInstance.Invoke
Dim DataStreams As PSDataStreams = PowerShellInstance.Streams
PSOutput.Dump
DataStreams.Dump
PowerShellInstance.Dispose
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。