powershell xls 1
ExcelファイルをCOMオブジェクトで読む。
$xls = "a.xls"
#new
$eo = New-Object -ComObject Excel.Application
$book = @()
# open
$eo.Workbooks.Open($xls) | %{
# sheets
$sheet = @()
$_.Worksheets | %{
# rows
$row = @()
$_.UsedRange.Rows | %{
# cols
$col = @()
$_.Columns | %{
$col += $_.Text
}
$row += $col
}
$sheet += $row
}
$book += $sheet
}
# quit
$excel.Quit()
[System.Runtime.InteropServices.Marshal]::FinalReleaseComObject($excel) | Out-Null