SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need to delete last row in Excel sheet using SSIS script task


Need to delete last row in Excel sheet using SSIS script task

Author
Message
raghava_tg
raghava_tg
SSC-Enthusiastic
SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)

Group: General Forum Members
Points: 160 Visits: 317
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.
Jitendra Padhiyar
Jitendra Padhiyar
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1218 Visits: 674
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'
raghava_tg
raghava_tg
SSC-Enthusiastic
SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)

Group: General Forum Members
Points: 160 Visits: 317
Thanks jitendra. i will try your solution.

But i am looking for Script Task.

Thanks in advance.:-)
raghava_tg
raghava_tg
SSC-Enthusiastic
SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)

Group: General Forum Members
Points: 160 Visits: 317
Hi to all.

i didnt got any reply . am i missing any information ?
snsingh
snsingh
SSC-Enthusiastic
SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)

Group: General Forum Members
Points: 161 Visits: 282
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
raghava_tg
raghava_tg
SSC-Enthusiastic
SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)

Group: General Forum Members
Points: 160 Visits: 317
Thanks sneh.

it is working fine....
sbkotcd
sbkotcd
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search