SSIS Script task to Delete The 2nd row in a Excell file
we want to Delete the 2nd row from the Excel file where 1st row Contains Headings .
Here is the script task component code to delete 2nd row from the Excel .
Major Steps : Create Excel.Application Object
Open work of the Given Excel file
Open sheet
Delete the Entire row of Cell A2 using Entirerow,Delete
Save The workbook
Quit the excel
Dim filename As String
Dim appExcel As Object
Dim newBook As Object
Dim oSheet1 As Object
appExcel = CreateObject("Excel.Application")
filename = "C:\test.xls"
appExcel.DisplayAlerts = False
newBook = appExcel.Workbooks.Open(filename)
oSheet1 = newBook.worksheets("Sheet1")
oSheet1.Range("A2").Entirerow.Delete()
newBook.SaveAs(filename, FileFormat:=56)
appExcel.Workbooks.Close()
appExcel.Quit()
Here is the script task component code to delete 2nd row from the Excel .
Major Steps : Create Excel.Application Object
Open work of the Given Excel file
Open sheet
Delete the Entire row of Cell A2 using Entirerow,Delete
Save The workbook
Quit the excel
Dim filename As String
Dim appExcel As Object
Dim newBook As Object
Dim oSheet1 As Object
appExcel = CreateObject("Excel.Application")
filename = "C:\test.xls"
appExcel.DisplayAlerts = False
newBook = appExcel.Workbooks.Open(filename)
oSheet1 = newBook.worksheets("Sheet1")
oSheet1.Range("A2").Entirerow.Delete()
newBook.SaveAs(filename, FileFormat:=56)
appExcel.Workbooks.Close()
appExcel.Quit()
do i need to add any references ? to use this script.
ReplyDeleteHello, do i need to add any references ? to use this script. I have almost whole script green underlined. it says something about class hierarchy. I don't know exactly what does it mean, i am not familiar with script task. I am using vb script tak 2017. Thanks a lot.
ReplyDelete