chicks
14 years agoRegular Contributor
Excel column returns null for non-numeric characters
Anybody seen anything like this or have any comments?
short version
=========
When I tried to use aqConvertVarToStr on values in an excel column that had non-numeric characters, I got either a null value or an empty string
back (not sure which).
I created a new excel column, copied the data cells from the old column and the values were read in properly.
When I copied the failing column to a new column, the error continued.
long version
=========
I was trying to read a zipCode. zipCodes with the 5 digit format without a dash e.g. 75081 were being read successfully.
Zip codes with the extended format e.g. 75081-0012 were coming in as null or the empty string.
The cells are of 'general' format. I discovered that it was any non-numeric character that caused a null value.
I wasn't sure whether it was the aqConvert or the dataDriver.Value that was coming in wrong.
Apparently it is the dataDriver.value that shows up as empty when the problem is happening.
I eventually realized that I had other columns with non-numeric values that were working properly.
Here's some code:
function debugZipCode () {
// zip code values with a - included are being read as empty strings
// appears to be column specific. If I create a new column values are
// read properly. If I copy the bad column, values are no longer read properly
Log.Message("debugZipCode");
Driver = DDT.ExcelDriver(excelData, signupSheet, true);
var omit;
var aURL;
while (! Driver.EOF() ) {
omit = aqConvert.VarToStr(Driver.Value(omitHeader));
// skip row if there's anything other than whitespace SignupWithConfirmationin the omit column
if ( /\S+/.test(omit) == false) {
// which environment
Log.Message("raw is "+Driver.Value(websiteHeader) ) ;
aURL = aqConvert.VarToStr(Driver.Value(websiteHeader));
Log.Message("aURL is "+aURL);
Log.Message("raw is "+Driver.Value(zipcodeHeader) ) ;
aZipCode = aqConvert.VarToStr(Driver.Value(zipcodeHeader));
Log.Message("zip is "+aZipCode);
}
Driver.Next();
}
DDT.CloseDriver(Driver.Name);
}
environment
========
Windows 7, Excel 2010, TestComplete 8.50.626.7
short version
=========
When I tried to use aqConvertVarToStr on values in an excel column that had non-numeric characters, I got either a null value or an empty string
back (not sure which).
I created a new excel column, copied the data cells from the old column and the values were read in properly.
When I copied the failing column to a new column, the error continued.
long version
=========
I was trying to read a zipCode. zipCodes with the 5 digit format without a dash e.g. 75081 were being read successfully.
Zip codes with the extended format e.g. 75081-0012 were coming in as null or the empty string.
The cells are of 'general' format. I discovered that it was any non-numeric character that caused a null value.
I wasn't sure whether it was the aqConvert or the dataDriver.Value that was coming in wrong.
Apparently it is the dataDriver.value that shows up as empty when the problem is happening.
I eventually realized that I had other columns with non-numeric values that were working properly.
Here's some code:
function debugZipCode () {
// zip code values with a - included are being read as empty strings
// appears to be column specific. If I create a new column values are
// read properly. If I copy the bad column, values are no longer read properly
Log.Message("debugZipCode");
Driver = DDT.ExcelDriver(excelData, signupSheet, true);
var omit;
var aURL;
while (! Driver.EOF() ) {
omit = aqConvert.VarToStr(Driver.Value(omitHeader));
// skip row if there's anything other than whitespace SignupWithConfirmationin the omit column
if ( /\S+/.test(omit) == false) {
// which environment
Log.Message("raw is "+Driver.Value(websiteHeader) ) ;
aURL = aqConvert.VarToStr(Driver.Value(websiteHeader));
Log.Message("aURL is "+aURL);
Log.Message("raw is "+Driver.Value(zipcodeHeader) ) ;
aZipCode = aqConvert.VarToStr(Driver.Value(zipcodeHeader));
Log.Message("zip is "+aZipCode);
}
Driver.Next();
}
DDT.CloseDriver(Driver.Name);
}
environment
========
Windows 7, Excel 2010, TestComplete 8.50.626.7