The formatting of dates is not carried over to new cells after Copy and paste

Posted by: nvnhat.17ck1 on 28 December 2023, 10:28 am EST

  • Posted 28 December 2023, 10:28 am EST - Updated 28 December 2023, 10:33 am EST

    Issue Description:

    We have identified a loss of date and time formatting in SpreadJS during certain operations.

    Step reproduce:

    *1. Open SpreadJS and input data containing a date format (e.g., 02/01/2023) into a cell.

    *2. Select the cell with the date format.

    *3. Click on “Number Format” and choose “Long Date.”

    *4. Copy the cell with the newly formatted date.

    *5. Paste the copied cell into another location.

    *6. Delete the cell where the data was pasted.

    *7. Attempt to paste the data again.

    Observation:

    Upon performing the above steps, we observe a formatting issue related to date and time. The expected behavior is to maintain the long date format throughout these operations, but there seems to be a loss of formatting during the copy-paste-delete-paste sequence.

    Expected Outcome:

    The date and time formatting should persist consistently even after multiple copy, paste, and delete actions.

    2023-12-28 21-16-49.zip

  • Posted 28 December 2023, 10:37 am EST

    Please use the attachment files to verify.Loss formatting.zip

  • Posted 29 December 2023, 7:51 am EST

    Hi,

    In Excel, pressing the delete key resets the internal clipboard, and you can verify this by attempting to paste after pressing delete in Excel. However, the copy-paste behavior in SpreadJS with Ctrl+C and Ctrl+V works differently. It utilizes both the system clipboard and internal clipboard but gives preference to the system clipboard.

    Here’s how the copy-paste process works in SpreadJS with Ctrl+C and Ctrl+V:

    1. When copying content in the worksheet with Ctrl+C, SpreadJS performs an internal copy (marking the range in the internal clipboard) and an external copy (writing the copied content into the system clipboard).

    2. When pasting with Ctrl+V in the worksheet, SpreadJS retrieves the content from the system clipboard and compares it with the internal clipboard. If they differ, it pastes the content from the system clipboard. If they are the same, it handles the paste internally, copying all data (value, style, formula, conditional format, data validation, etc.) from the source cell and pasting it into the targeted cell.

    So, when you copy with Ctrl+C, the system clipboard contains “Wednesday, February 01, 2023,” and the internal clipboard has information about the range of cells. Upon pasting for the first time, the content is pasted internally because the system clipboard and internal clipboard match. If you press delete on the targeted cell, the dashed style on the border of the source cell is removed, indicating that the internal clipboard is reset and no longer has information about the source cells. Only the value was cleared in the targeted cell, but the cell still has the date format.

    Now, after pressing delete, if you try to paste again on the same cell (which still has the date format), and the internal clipboard has no information about the source cells, the system clipboard data will be pasted. However, the observed behavior is that SpreadJS is showing “2/1/2023” instead of “Wednesday, February 01, 2023.” This has been escalated to the developer, and I will update you as soon as I receive more information. The internal tracking id for the same is: SJS-22113

    Best regards,

    Ankit

  • Posted 29 December 2023, 8:43 am EST

    Hi Ankit,

    Big thanks for diving deep into the SpreadJS matter and keeping me posted on the detective work with tracking ID SJS-22113. Your breakdown of the issue is spot-on, and I’m grateful for the detailed overview.

    Best regards,

    Nhat

  • Posted 2 January 2024, 12:37 am EST

    Hi Nhat,

    We will keep you updated on the escalated case as we receive an update from the dev team.

    Regards,

    Ankit

  • Posted 9 January 2024, 8:50 am EST

    Hi,

    The devs have mentioned that this is a known limitation. SpreadJS’s clipboard judgment logic will judge current behavior is internal copy paste.

    Then, all the content from B2 (value, style, formula….) will copy from B2 to B4.

    Then, when you delete B4, you will find that the clipboard indicator disappear, that means, the internal clipboard have been cleared. (limited by the platform, we could not clear the system clipboard).

    Then when you paste content to B4, SpreadJS will handle this behavior as external pasting behavior.

    Then the content “Wednesday, February 01, 2023” will be pasted to the cell, and the cell original auto-formatter “[$-409]dddd, mmmm dd, yyyy” will be used to parse the text to value, and a date will apply to cell, and the original formatter cleared.

    I hope this clarifies the behavior. Let me know if you still have any doubts. As mentioned earlier, in Microsoft Excel also, pressing the delete keys resets the internal clipboard.

    Regards,

    Ankit

Need extra support?

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

Learn More

Forum Channels