DDT.ExcelDriver Sometimes Truncates Long Strings at 255 characters.
Hi
I am using the DDTDriver - to drive my data driven tests using spreadsheet
ie. MainDriver = DDT.ExcelDriver(Path + Workbook, Sheet, true);
I have found, on some of the sheets I have in my workbook, it sometimes truncates long strings held in cells in the sheet to 255 chars. ie [ observe = aqConvert.VarToStr(DDT.CurrentDriver.Value(i)); so that the variable 'observe' contains a string that is only 255 chars long, but the value held in the spreadsheet cell is actually much longer ]
BUT oddly it does not do this all the time!
I have a spreadsheet with 4 columns and 11 rows
The first row holds the column names
The next 10 rows hold the data under those columns.
In the 3rd column on the last row (by using DDT.CurrentDriver.Next() as I move through the rows )- the cell holds the lengthy string value. I get its value using aqConvert.VarToStr(DDT.CurrentDriver.Value(2)); - and the value retrieved, is always a truncated string 255 chars long.
If I remove a 2 rows above, in the spreadsheet, so it is now only 8 rows long (it does not matter which rows I remove) the cell that holds the lengthy string now correctly has all the characters retrieved from the spreadsheet cell!
Any suggestions why this odd behaviour may be happening?
Has anyone experienced the same or found a solution? I am using Excel 2016. I have tried with and without the ACEDriver parameter value ie true/false but that makes no difference.
Many Thanks in advance
Hi, I think I have found the cause. 😀
I found this section in the documentation:
-
The Excel ODBC driver can truncate cell data to 255 symbols. To determine the data type of a column, Excel scans the column cells of the first 8 rows. If each of these cells contains text shorter than 256 characters, all the subsequent cell values will be truncated to 255 symbols. For more information, see docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/initializing-the-microsoft-excel-driver.
It would explain the behaviour. Adding it so others might also benefit from it. (Simple solution is to include a long string in the first 8 rows of your DDT test, then other rows will not be truncated).
-