- What code should I insert into the script to delete rows? (I suppose right after
//Load the DataTable with Sheet Data so we can get the column header); or
- How to modify this code to make it read excel files starting from Row 13; or, alternatively
- What SSIS task should I insert before the script for bulk row deletion?
This is a method for looping through sheets:
Create a data flow task to read sheet names into ADO object.
First item is a script component as a source.
I have a variable for connection string to the Excel Spreadsheet
Created an Output of SheetName
You are basically opening the spreadsheet with oleDB.
Putting the table names into a data table
Looping through the data table and writing out the rows to output.
Make sure to close the Connection!!! This may cause errors later if you don’t.
The next step is a conditional split as for some reason the result has duplicates of tab names and they all end in an ‘_’.
Next step is deriving a column to clean the sheet name of exta “‘”
Create a Variable of type Object: I named mine ADO_Sheets
Insert a recordset destination object:
1. Set the variable to the variable you just created
2. Map the columns for clean Sheet
Configure the foreach…
Enumerator: Foreach ADO Enumerator
Variable Mapping: Set to a variable called SheetName
This variable is now your select for extracting the data off that page.
Last is the data flow task you want to run.
Lot’s of work, but I use this so often I thought I would share!!!
Adding info about connection strings to Excel (xlsx)
Connect to Excel 2007 (and later) files with the Xlsx file extension. That is the Office Open XML format with macros disabled.
Extended Properties=”Excel 12.0 Xml;HDR=YES”;
“HDR=Yes;” indicates that the first row contains columnnames, not data. “HDR=No;” indicates the opposite.