In percent-formatted cells, Excel will place a '%' as the user types. This allows 50% to be entered as '50'. Steps (excel and kendo): 1. Format a cell as percent 2. Enter 50 Excel shows "50.00%". The actual value is .5 Kendo widget shows "5000.00%". The actual value is 50
var
skipSet =
false
;
$(
'#spreadsheet'
).kendoSpreadsheet({
change:
function
(e) {
if
(skipSet) {
skipSet =
false
;
return
;
}
var
range = e.range;
var
format = range.format();
if
(format ===
"#.00%"
) {
skipSet =
true
;
range.value(range.value() / 100);
}
},
sheets: [{
rows: [{
cells: [{
format:
"#.00%"
}]
}]
}]
});
The format of a cell must only change its appearance and not its value. In particular, the percentage format must multiply the actual value by 100 and show a "%" symbol. This is what the description of this format says in Excel too.
It seems, however, that in Excel the actual value changes with that multiplier, and so the data is changed, not just formatted.
The Kendo Spreadsheet preserves the data and applies a display format which is a correct behavior.
If you type the % symbol as well, you will get the desired behavior because the format will be matched to the value and so the conversion will occur. For example, type "50%" in the Kendo Spreadsheet instead of "50" in the percent cell and you will see the difference.
Without the % symbol, the value would have to be changed heuristically, and such logic is not yet implemented in the Kendo Spreadsheet.