title: Read Excel cell values with SSIS script task
body: <p>I am trying to read an Excel file via a <strong>SSIS ScriptTask</strong> to check for certain cell values in that worksheet.  </p>
  
  <p>In the code example you can see that the <strong>strSQL</strong> is set to "<strong>H4:H4</strong>" to only read one cell. This cell can only have a true or false value.
  Since I also need to check for a certain string value in <strong>B1</strong> I wanted to extend this version.   </p>
  
  <pre><code>  string filePath = "c:\\test\\testBoolean.XLSX";
    string tabName = "testSheet$";
    string strSQL = "Select * From [" + tabName + "H4:H4]";
    String strCn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
                    + filePath + ";Extended Properties=\"Excel 12.0;HDR=NO;IMEX=1\";";
    OleDbConnection cn = new OleDbConnection(strCn);
    int iCnt = 0;
    OleDbDataAdapter objAdapter = new OleDbDataAdapter(strSQL, cn);
    DataSet ds = new DataSet();
    objAdapter.Fill(ds, tabName);
    DataTable dt = ds.Tables[tabName];
  
    foreach (DataRow row in dt.Rows)
    {
        iCnt = iCnt + 1;
        // some processing....
    }
  </code></pre>
  
  <p>What I don't understand is why I get a boolean value with the above <strong>strSQL</strong> statement or with any statment containing the same row number like so:</p>
  
  <pre><code>string strSQL = "Select * From [" + tabName + "F4:H4]";
  </code></pre>
  
  <p>Debug-Output:</p>
  
  <pre><code>row.ItemArray[2]    false   object {bool}
  </code></pre>
  
  <p><strong>But</strong> when I set a different range like this one:</p>
  
  <pre><code>string strSQL = "Select * From [" + tabName + "F1:H4]";
  </code></pre>
  
  <p>I loose the recognition of the bool value:</p>
  
  <pre><code>row.ItemArray[2]   "FALSE"  object {string}
  </code></pre>
  
  <p>I'd much rather like to use the bool value for other processing tasks.</p>
  
  <p>How can I fix this in addition to also reading the B2 value?</p>