We have often encountered bugs around datatype of data being written in spreadsheets. For example string like 8E45000 getting converted into a floating type or a string like 4D or 4F getting converted to numeric etc.
The internal logic used to extract the data type of the data sometimes isnt that accurate and we would end up in writing corrupted data in spreadsheets.
With Splendor now we provide users with the option of specifying the datatype of the data being written in spreadsheets. In this way we can avoid the internal logic of determining the datatype which sometimes used to corrupt the data.
This option will be supported in these 3 mehotds : SpreadSheetAddRow,SpreadSheetAddRows,SpreadSheetSetCellValue
Possible datatype of a cell can be : STRING, NUMERIC or DATE
Here is the syntax :
SpreadSheetAddRow( ExcelInfo excelvar, String value, int row, int column, boolean insert,String datatype )
where ‘datatype’ is an expression which describes the datatype of data.
Here are examples :
STRING:1,3;NUMERIC:2 –> Data in 1st and 3rd column of this row will be of type string, and that of 2nd column of type numeric
NUMERIC:1;STRING –> Data in 1st column of this row will be of type numeric, rest all will be of type string
NUMERIC:2-5;STRING:1,6;DATE –> Data in 1st and 6th column of this row will be of type string and data from 2nd to 5th column will be numeric and rest of type date.
STRING –> All cells in this row will be of type string
string;numeric:3,4 –> This is an invalid expression. Only last in the sequence can skip mentioning column numbers. In that case we will assume rest all columns will be of that datatype. For example this will work :NUMERIC:3,4;STRING
If for any cell datatype is not specified, it will fallback to old way of extracting the datatype.
Similarly we take datatype attribute in other methods also :
SpreadSheetAddRows( ExcelInfo excelvar, Object q, int startrow, int startcolumn, boolean insert,Object datatypes )
Where ‘datatypes’ will be an array of datatype expressions
SpreadSheetSetCellValue( ExcelInfo excelvar, String value, int row, int column, String datatype )
Where ‘datatype’ is datatype of the cell