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()

Comments

  1. do i need to add any references ? to use this script.

    ReplyDelete
  2. Hello, 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

Post a Comment

Popular posts from this blog

SSAS : A connection cannot be made to redirector. Ensure that 'SQL Browser' service is running. (Microsoft.AnalysisServices.AdomdClient). + Solution

SSIS Error : Unable to infer the XSD from the XML file. The XML contains multiple namespaces