Chris's profileChris Burrows' Live Spac...PhotosBlogListsMore ![]() | Help |
|
September 14 How to force the Column Data Type when using Excel in Data Driven TestsWhere 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. TrackbacksThe trackback URL for this entry is: http://madtechnology.spaces.live.com/blog/cns!F637E4FD356E127D!130.trak Weblogs that reference this entry
|
|
|