LoginSignup
23
23

More than 1 year has passed since last update.

PowerShellでExcelファイルを読み込んでみる

Last updated at Posted at 2013-10-19

2022/5/3
当記事の内容をもっと詳しくしてみました。よろしければご参照ください。
PowerShellでExcelファイルをCSV形式に変換する - Qiita


次のような感じで、Excelファイルを読み込めました。

詳細は、GitHubを参照。
https://github.com/kurukurupapa/TryPowerShell/blob/master/Excel001_Read.ps1

# Excelを起動する
$excel = New-Object -ComObject Excel.Application

# ブックを開く
$excel.Workbooks.Open("${baseDir}\TestData\Excel001_Data.xls") | %{
    # シートを読み込み
    $_.Worksheets | %{
        # 行を読み込む
        $_.UsedRange.Rows | %{
            # 列を読み込む
            $_.Columns | %{
                Write-Output $_.Text
            }
        }
    }
}

# Excelを終了する
$excel.Quit()
[System.Runtime.InteropServices.Marshal]::FinalReleaseComObject($excel) | Out-Null
23
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
23