$excel = New-Object -ComObject Excel.Application $excel.Visible = $false $book = $excel.Workbooks.Open($args[0]) $sheet = $book.Sheets('Sheet1') $data = @() # 全範囲 $sheet.UsedRange.Rows | ForEach-Object { $row = @($_.Columns).Text; $data += $row -join "`t" } # 指定範囲 # $sheet.Range("A1:C5").Rows | ForEach-Object { $row = @($_.Columns).Text; $data += $row -join "`t" } # クリップボード $data -join "`n" | Set-Clipboard # TSVで書き出し $data -join "`n" | Out-File -Encoding UTF8 .\outfile.tsv $excel.Quit() $excel = $null [GC]::Collect()