Issue when input date time in SpreadJS Designer

Posted by: thuan.tu on 27 December 2023, 3:58 pm EST

    • Post Options:
    • Link

    Posted 27 December 2023, 3:58 pm EST

    Hi support team!

    We are using SpreadJS Designer. When we enter a date value into a cell in the spreadsheet, we see that the cell format is displaying incorrectly. We see that the toolbar is displaying the cell’s data type as Date, but in Format Cells it is General. This behavior seems to be different from MS excel tool. Please see my attached for more details. If this is an error, can you fix it for us? Thanks!

  • Posted 27 December 2023, 5:02 pm EST

  • Posted 27 December 2023, 11:20 pm EST

    Hi,

    I am Ankit from SpreadJS Support Team.

    Thanks for sharing the video with us. We were able to replicate the issue at our end. It does seem like an issue with the SpreadJS and also doesn’t match with the Microsoft Excel’s behavior.

    I have escalated this to the concerned dev team for further investigation. The internal tracking id for the same is SJS-22110. I will let you know when there is further info on this from the dev team.

    Currently, there is no workaround to achieve the behavior of Microsoft Excel.

    Also, for SpreadJS related issues/queries, kindly create a case on dedicated SpreadJS Portal at: https://developer.mescius.com/forums/spreadjs

    Regards,

    Ankit

  • Posted 3 January 2024, 10:11 pm EST

    Hi,

    The devs have mentioned that this is a known difference with Microsoft Excel. When SpreadJS inputs a value into the cell, the auto-formatter policy will try to parse the inputting string to a value, and then save the auto-formatter in the cell, and the cell’s formatter is still undefined.

    But in MS Excel, when you doing the same behavior, a date formatter will be applied to the cell directly.

    The devs have mentioned that as a component, we should not pollute user data (the cell style is kind of user data).

    However, if you want to achieve the same as MS Excel, you could monitor the CellChanged, set the autoFormatter to the cell formatter. You could use the following code snippet:

    spread.bind(GC.Spread.Sheets.Events.CellChanged, function (evt, args) {
        if (args.propertyName === '[styleinfo]' && !args.oldValue && 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);
        }
    });

    Sample: https://jscodemine.grapecity.com/share/hu0IwiUOFE6B_tBOk8EbyA/?IsEmbed=false&Theme=Unset&PreviewDirection=0&IsEditorShow=true&IsExplorerShow=true&IsPreviewShow=true&IsConsoleShow=true&IsRunBTNShow=false&IsResetBTNShow=false&IsOpenInCodemineBTNShow=false&PanelWidth=20&PanelWidth=50&PanelWidth=30&defaultOpen={"OpenedFileName"%3A["%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.js"}

    Cell Changed Event: https://developer.mescius.com/spreadjs/api/v16/classes/GC.Spread.Sheets.Events#cellchanged

    Regards,

    Ankit

  • Posted 4 January 2024, 10:02 pm EST

    Thanks Ankit!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels