0 Pluspunkte 0 Minuspunkte

Ich habe diesen Code um ein Blatt in einer Excel Arbeitsmappe zu löschen.

#Specify the path to the Excel file and the WorkSheet Name
$FilePath = "C:\Users\tobias\test.xlsx"
$SheetName = "Sheet4"

#Create an Object Excel.Application using Com interface
$objExcel = New-Object -ComObject Excel.Application

#Disable the 'visible' property so the document won't open in excel
$objExcel.Visible = $false

#Set Display alerts as false
$objExcel.displayalerts = $False

#Open the Excel file and save it in $WorkBook
$WorkBook = $objExcel.Workbooks.Open($FilePath)

#Load the WorkSheet 'BuildSpecs'
$WorkSheet = $WorkBook.sheets.item($SheetName)

#Deleting the worksheet
$WorkSheet.Delete()

#Saving the worksheet
$WorkBook.Save()
$WorkBook.close($true)
$objExcel.Quit()

Wie kann ich eine Zeile aus dem Blatt entfernen?

von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

So kannst du die 3 Zeile aus dem Worksheet löschen.

$WorkSheet.Rows.Item(3).Delete()
von (716 Punkte)