0
我写了一个具有oracle连接属性的函数Get-oracleresultDa。通过它我可以查询我的数据库。使用powershell将查询结果导出到excel表格
但是,问题是,我尝试将数据导出到Excel工作表它只返回所述第二查询即的结果)没有状态 而不是没有类型
$results = Get-OracleResultDa -conString $connectionString -sqlString $query
-Verbose
$results | SELECT no, type| Export-CSV "H:\Book2.csv" -Force
$rows++
$results1 = Get-OracleResultDa -conString $connectionString -sqlString
$created -Verbose
$results1 | SELECT no, status| Export-CSV "H:\Book2.csv" -
NoTypeInformation
下面提到的块是在第10 linesof脚本
$file="H:\Book2.csv"
$excel = New-Object -ComObject excel.application
#Makes Excel Visable
$excel.Application.Visible = $true
$excel.DisplayAlerts = $false
#Creates Excel workBook
$book = $excel.Workbooks.Add()
#Adds worksheets
#gets the work sheet and Names it
$sheet = $book.Worksheets.Item(1)
$sheet.name = 'Created'
#Select a worksheet
$sheet.Activate() | Out-Null
我有几多个查询的还因为如果你使用PowerShell 3.0或贝特要出口