Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8939851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:54:33+00:00 2026-06-15T10:54:33+00:00

I am trying to read an Excel file via a SSIS ScriptTask to check

  • 0

I am trying to read an Excel file via a SSIS ScriptTask to check for certain cell values in that worksheet.

In the code example you can see that the strSQL is set to “H4:H4” 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 B1 I wanted to extend this version.

  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....
  }

What I don’t understand is why I get a boolean value with the above strSQL statement or with any statment containing the same row number like so:

string strSQL = "Select * From [" + tabName + "F4:H4]";

Debug-Output:

row.ItemArray[2]    false   object {bool}

But when I set a different range like this one:

string strSQL = "Select * From [" + tabName + "F1:H4]";

I loose the recognition of the bool value:

row.ItemArray[2]   "FALSE"  object {string}

I’d much rather like to use the bool value for other processing tasks.

How can I fix this in addition to also reading the B2 value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:54:35+00:00Added an answer on June 15, 2026 at 10:54 am

    Your connection string specified IMEX=1, which tells the driver to treat intermixed data types as text. (See the “Usage Considerations” section of the MSDN article Excel Connection Manager.)

    Thus, when you specified a single row

    string strSQL = "Select * From [" + tabName + "F4:H4]";
    

    there was only one possible data type for the third column, and the driver was able to correctly infer it. However, when you specified multiple rows

    string strSQL = "Select * From [" + tabName + "F1:H4]";
    

    and any value in the range H1:H4 was not a bool, the driver translated all values in that column to strings.

    Assuming that you do in fact have mixed data types in column H and only care about the values in two particular cells, the simplest solution is to query each cell individually. See Import a single Excel cell into SSIS for some ideas on how to do that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read an Excel file (.xls, I think Excel 2003 compatible) via
I'm trying to read an Excel (xlsx) file using the code shown below. I
I'm trying to write a stored procedure that will read an Excel file into
I am trying to read an Excel sheet that has some merged cells using
I am trying to read an Excel in Perl which have values in format
I'm trying to read data from excel using POI. How can I check if
I am trying to read in an XML file that I have saved to
I'm trying to read an excel file using an OleDb Reader, I couldn't debug
I am trying to read an Excel spreadsheet file with Ruby, but it is
I am trying to read in an Excel file using xlrd, and I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.