Posted 16 January 2024, 3:13 pm EST - Updated 16 January 2024, 3:18 pm EST
Wrong data type when Clear All -> input data -> Format Cell
Posted by: linh.nguyen.hoang on 16 January 2024, 3:13 pm EST
-
-
Posted 16 January 2024, 8:10 pm EST
Hi,
This is a known difference with Microsoft Excel. When SpreadJS inputs a value into a cell, the auto-formatter policy will try to parse the inputting string to a value, and then save the auto-formatter to the cell, and the cell’s formatter is still undefined.
However, in Microsoft Excel, when doing the same behavior, a date formatter will be applied to the cell directly.
As a component, we should not pollute the user’s data (the cell style is kind of user data). And if you would like to do the same as Microsoft Excel, you could monitor the CellChanged Event and then set the autoFormatter to the Cell Formatter. Kindly refer to the following code snippet and sample:
// Handle the Cell Changed Event spread.bind(GC.Spread.Sheets.Events.CellChanged, function (evt, args) { if (args.propertyName === '[styleinfo]' && args.newValue && args.newValue._autoFormatter) { var { sheet, row, col } = args; var style = sheet.getStyle(row, col); style.formatter = style._autoFormatter; sheet.setStyle(row, col, style); } });
Regards,
Ankit
-
Posted 16 January 2024, 8:13 pm EST
Thank you ! Work like a charm