Chris's profileChris Burrows' Live Spac...PhotosBlogListsMore Tools Help

Blog


    September 14

    How to force the Column Data Type when using Excel in Data Driven Tests

    Where I'm working at the moment we are using the new data driven tests to help us test different combinations of test data while using the same underlying test.   At the moment we are using an Excel spreadsheet to store the test data and the expected results and expected exception.    A while ago one of the team members grabbed me to look at a problem.  For a particular row of test data a specific cell value was not being flowed through to his test.   After looking at it for a while, I noticed that this contained text data, while the rest of them contained numeric data.    This then reminded me that the Excel ODBC Driver infers the columns data type from the first X rows. (I think it is 10 but am not 100% sure).   Therefore, as the majority of the data in this column was numeric, the column type in .NET was being set to decimal.     

    So how did we solve it.   First we tried just changing  the format of the column to text, but this did nothing.  So the next thing we tried was a little known feature in excel which if I remember correctly stems all the way back to the days when Excel was competing with Lotus 123.    One way of forcing the type of the cell from numeric to text is to place the ' character in front of the number.  For example if you want the number 1234 to be treated as text you would type in '1234.   This solved the problem, the columns type was now set to Text rather than numeric.

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://madtechnology.spaces.live.com/blog/cns!F637E4FD356E127D!130.trak
    Weblogs that reference this entry
    • None