﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Integration Services / Data Warehousing  / Extracting data from specific cell in Excel using Script task / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 02:44:04 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Extracting data from specific cell in Excel using Script task</title><link>http://www.sqlservercentral.com/Forums/Topic1431783-364-1.aspx</link><description>Any help guys..</description><pubDate>Sat, 16 Mar 2013 04:47:24 GMT</pubDate><dc:creator>rockstar283</dc:creator></item><item><title>Extracting data from specific cell in Excel using Script task</title><link>http://www.sqlservercentral.com/Forums/Topic1431783-364-1.aspx</link><description>Hi..I have an excel file with data and want to extract the value from C2 cell only..here is my code in script component:                               public void Main()        {            // TODO: Add your code here            string fileToTest;            string tableToTest;            string connectionString;            OleDbConnection excelConnection;            DataTable excelTables;            string currentTable;            fileToTest = Dts.Variables["ExcelFile"].Value.ToString();            tableToTest = Dts.Variables["ExcelTable"].Value.ToString();            string tabName = "TBL_NAME$";            //Dts.Variables["ExcelTableExists"].Value = false;            if (File.Exists(fileToTest))            {                connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +                "Data Source=" + fileToTest + ";Extended Properties=Excel 8.0";                excelConnection = new OleDbConnection(connectionString);                excelConnection.Open();                excelTables = excelConnection.GetSchema("Tables");                string strSQL = "Select * From [" + Dts.Variables["ExcelTable"].Value.ToString().Substring(1,16) + "C2:C2]";                OleDbDataAdapter objAdapter = new OleDbDataAdapter(strSQL, excelConnection);                DataSet ds = new DataSet();                objAdapter.Fill(ds, tabName);                DataTable dt = ds.Tables[tabName];                MessageBox.Show(ds.Tables[tabName].Rows[1].ToString());                foreach (DataRow row in dt.Rows)                {                    Dts.Variables["From_Date"].Value = row.ItemArray[1].ToString();                    MessageBox.Show( Dts.Variables["From_Date"].Value.ToString());                  }                //MessageBox.Show(Dts.Variables["From_Date"].Value.ToString());            }            Dts.TaskResult = (int)ScriptResults.Success;        } I am not getting anything at all..the messagebox shows nothing..Can anyone please tell me what am I doing wrong?</description><pubDate>Fri, 15 Mar 2013 15:11:10 GMT</pubDate><dc:creator>rockstar283</dc:creator></item></channel></rss>