BaseBallBatBoy
New Member
- Joined
- Sep 12, 2011
- Messages
- 24
Hi
I get Excel files with multiple worksheets. I need to find the one worksheet where there is true A1 = 'HeaderCol1' AND B1 = 'HeaderCol2' AND C1 = 'HeaderCol3'. Of this worksheet I need to know it's name.
This script will then be used in a script task in my SSIS package to dynamically find the correct worksheet to load the data from.
How can I do so?
By browsing I already found this:
<code>
</code><code></code>But this will only get the first worksheet's name. What I need is the name of the worksheet where my condition resolves to true.
Cheers
I get Excel files with multiple worksheets. I need to find the one worksheet where there is true A1 = 'HeaderCol1' AND B1 = 'HeaderCol2' AND C1 = 'HeaderCol3'. Of this worksheet I need to know it's name.
This script will then be used in a script task in my SSIS package to dynamically find the correct worksheet to load the data from.
How can I do so?
By browsing I already found this:
<code>
Code:
Excel.Application xlApp = new Excel.ApplicationClass();
Excel.Workbook xlWorkBook = xlApp.Workbooks.Open("<name of="" your="" excel="" app="">myFile.xls", 0, xlWorkBook true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
// Look up worksheet by index
Excel.Worksheet xlWorkSheet =(Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
//</name></code><code> FYI user::worksheetname is a SSIS variable </code><code>
user::worksheetname = xlWorkSheet.Name;
</code><code>
Cheers