Tuesday, 9 June 2015

SSIS - [ Read Excel File After Skipping Few Rows ]


Scenario:

We have excel file with Sheet1 as shown below. We want to skip first 3 rows as they are only description and start reading from 4th Row. The 4th Row contains Header and rest of them are data rows.


Solution :

Step 1: 
Lets create connection for Excel Source as shown below


Go to Extended properties and set HDR=YES, means the file has header(First Row as header)

With all above changes we are done with configuration for our excel 

Step 2: 
Lets place Data Flow task on Control Flow Pane and then get OLE DB Source and configure as shown below.

The query I used is 
Select * from [Sheet1$A4:D]

I did not put any number with D that means we want to read all the rows. lets say we want to read first ten rows then our query will look like this
Select * from [Sheet1$A4:D10]

Final Output: 

I used multicast as destination so I can put Data Viewer between Source and Multicast to show the records.
As we can see that our Source skipped first 3 rows and start reading from 4th row.