LoginSignup
6
6

More than 5 years have passed since last update.

powershellでエクセルのシートを削除する

Posted at

解説しているところが見つからなかったのでメモ

# Excelオブジェクト作成
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$excel.DisplayAlerts = $false

# エクセルを開く
$book = $excel.Workbooks.Open("C:\work\work1.xls")

#hogeシートを削除
$excel.worksheets.item("hoge").delete()

# 上書き保存
$book.Save()

# 閉じる
$excel.Quit()

# プロセスを解放する
$excel = $null
[GC]::Collect()
6
6
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
6
6