Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Need to delete last row in Excel sheet using SSIS script task Expand / Collapse
Author
Message
Posted Monday, July 09, 2012 11:49 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 2:25 AM
Points: 52, Visits: 266
Hi to all.

I need to delete last row in excel in sheet using ssis task. can any help me regarding this?

Please do let me know in case of any additional information required.

Thanks in advance.
Post #1327014
Posted Monday, July 09, 2012 11:57 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 5:51 AM
Points: 203, Visits: 538
1. Connect to the excel sheet using JET oledb.

2. Query the whole sheet and create a datatable which contains the excel data now.

3. Delete the first row of Datatable.

4. Update the datatable using Dataadapter (This will update the change to excel)


OR

Use update command as below:

update `Sheet Name`
set [Column Name]=null where [Condition Column Name] = 'Sample'
Post #1327019
Posted Monday, July 09, 2012 12:16 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 2:25 AM
Points: 52, Visits: 266
Thanks jitendra. i will try your solution.

But i am looking for Script Task.

Thanks in advance.
Post #1327035
Posted Tuesday, July 10, 2012 5:01 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 2:25 AM
Points: 52, Visits: 266
Hi to all.

i didnt got any reply . am i missing any information ?
Post #1327424
Posted Tuesday, July 10, 2012 5:35 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, March 31, 2014 3:49 AM
Points: 24, Visits: 217
try using sql script task-

Dim filename As String
Dim appExcel As Object
Dim newBook As Object
Dim oSheet1 As Object
Dim cell As String
Dim rowcount As Int16


appExcel = CreateObject("Excel.Application")
filename = "C:\Documents and Settingsbkrrov\Desktop\test.xls"
appExcel.DisplayAlerts = False

newBook = appExcel.Workbooks.Open(filename)
oSheet1 = newBook.worksheets("Sheet1")
rowcount = oSheet1.UsedRange.Rows.Count()
cell = "A" + rowcount.ToString
oSheet1.Range(cell).Entirerow.Delete()


With newBook
.SaveAs(filename, FileFormat:=56)


End With
appExcel.Workbooks.Close()
appExcel.Quit()


Thanks
Sneh
Post #1327452
Posted Tuesday, July 10, 2012 6:04 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 2:25 AM
Points: 52, Visits: 266
Thanks sneh.

it is working fine....
Post #1327471
Posted Wednesday, October 10, 2012 12:39 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 30, 2013 2:01 PM
Points: 2, Visits: 11
I am trying to do something similar, but I cannot figure out how to close the excel instance from task manager. Any assistance? code snippet below

Public Sub Main()
'
Dim objExcel As Object
objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open("*.xls")
objExcel.displayalerts = False
objExcel.Sheets("*").Select()
objExcel.rows("2:50000").delete()
objExcel.Workbooks(1).Save()
objExcel.Workbooks.Close(False)
objExcel.displayalerts = True
objExcel = Nothing
Post #1371083
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse