Auto convert OADate when Copy Paste (CTRL + C, CTRL + V) a number string

Posted by: nguyenvu.work on 24 August 2026, 5:48 am EST

    • Post Options:
    • Link

    Posted 24 August 2026, 5:48 am EST

    Hi!

    I’m having an issue when I copy-paste a plain number (2026) from Notepad into a cell in my .sjs file using Ctrl + V.

    In the underlying JSON, the cell value becomes “value”: “/OADate(2026)/” instead of 2026. This breaks my custom function because it expects a NUMBER, not a DATE.

    I suspect the cell had cached a date format previously. After unzipping the .sjs file and checking style.json, I found this:

    "sharedObjects": [
        "{\"formatCached\":\"yyyy/m/d\"}",
        "{}"
    ]
    

    Could this be causing the issue? If my assumption is correct, what specific actions lead to this date formatting being cached?

  • Posted 24 August 2026, 8:35 am EST

    Hi,

    Thank you for providing the details. Yes, your assumption is correct. The cached

    formatCached: "yyyy/m/d"
    on the target cell’s style can cause the pasted value
    2026
    to be interpreted as a date rather than a number.

    Why this happens

    When the target cell has a date formatter such as

    yyyy/m/d
    , SpreadJS uses that formatter to parse the incoming value.

    When you copy the plain text

    2026
    from Notepad and paste it into the cell:

    1. Notepad provides only plain text, without any formatting information.
    2. SpreadJS uses the destination cell’s formatter to parse the incoming text.
    3. Because the destination cell has a date formatter (
      yyyy/m/d
      ), the numeric text
      2026
      is interpreted as an OADate serial number.
    4. As a result, the underlying value becomes a DateTime value and is serialized in the
      .sjs
      file as:
    "value": "/OADate(2026)/"

    This is also why the issue is not specific to the clipboard. Typing

    2026
    directly into the same date-formatted cell would produce the same behavior.

    What causes the date formatter to be cached?

    The

    yyyy/m/d
    formatter can be introduced by several actions, including:

    • Setting a formatter directly:
    sheet.setFormatter(row, col, "yyyy/m/d");

    or:

    sheet.getCell(row, col).formatter("yyyy/m/d");
    • Assigning a
      GeneralFormatter
      to the cell style.
    • Applying a Date or custom date format through the Format Cells dialog in Designer.
    • Importing an Excel or SJS file where the cell, row, column, or sheet default style contains a date formatter.
    • Pasting formatting from another date-formatted cell when using clipboard options that include formatting.
    • Applying a formatter at the row, column, or sheet default-style level. In this case, the individual cell may appear to have no explicit formatter, but it can still inherit the date formatter.

    The

    formatCached
    entry in
    style.json
    is therefore an indication that the date formatter has been cached for the corresponding style.

    Recommended solution

    If the cell is expected to contain numeric values, the preferred solution is to reset its formatter to

    General
    before pasting:

    sheet.setFormatter(row, col, "General");

    You should also check whether the formatter is being inherited from a row, column, or sheet-level default style if resetting the cell formatter does not resolve the issue.

    Please note that if the date formatter remains applied, the cell may still display the value according to the date format. Resetting the formatter is therefore recommended if the cell is intended to represent a number.

    Regards,

    Priyam

  • Posted 24 August 2026, 11:02 pm EST

    • Here is the log information I got for the cell’s values:
    • CellType: undefined
    • Formatter: =LET(kind,SUBSTITUTE(SUBSTITUTE(TRIM(INDEX($W:$W,ROW())&“”)," “,”“),” “,”“),unitK,SUBSTITUTE(SUBSTITUTE(TRIM(INDEX($X:$X,ROW())&”“),” “,”“),” “,”“),modeIn,TRIM(INDEX($Y:$Y,ROW())&”“),decIn,TRIM(INDEX($Z:$Z,ROW())&”“),val,@,isEmpty,LEN(TRIM(val&”“))=0,isNum,ISNUMBER(val),modeUnset,OR(LEN(modeIn)=0,modeIn=”-“,modeIn=“ー”,modeIn=”-“,modeIn=“−”),decUnset,OR(LEN(decIn)=0,decIn=”-“,decIn=“ー”,decIn=”-“,decIn=“−”),isPct,OR(kind=“a”,unitK=”%“,unitK=”%“),isSen,OR(kind=“o1”,unitK=“o2”),isBai,OR(kind=“p”,unitK=“p”),isDecimal,OR(isPct,isSen,isBai),defDec,IFS(isPct,1,isSen,2,isBai,1,TRUE,0),dec,IF(decUnset,defDec,IFERROR(MAX(0,INT(decIn)),defDec)),mode,IF(modeUnset,“m1”,modeIn),target,IF(isDecimal,val,val/POWER(10,dec)),digits,IF(isDecimal,dec,0),fmt,IF(AND(isDecimal,dec>0),”#,##0.“&REPT(“0”,dec),”#,##0"),rounded,SWITCH(mode,“xxx”,MY_FUNCTION(target,digits),“vvv”,MY_FUNCTION(target,digits),“x1”,MY_FUNCTION(target,digits),NA()),result,IF(isEmpty,“”,IF(NOT(isNum),val,IF(ISNA(rounded),val,TEXT(rounded,fmt)))),result)
    • Could the custom formatter above be the reason why the cell gets converted to a Date format when pasting 2026? If so, please point out the exact line or part causing it!
    • I still don’t fully understand why, when using the destination cell’s formatter, it detects and retrieves the specific value inside formatCached to apply to that cell. Which specific properties or metadata in the .json files define/determine this behavior?
    • Since I need to explain the root cause and details to my client, I require more technical specifics, particularly how to reproduce the issue where a cell caches a DATE formatter. It would be very helpful if you could provide a step-by-step reproduction guide for this behavior (in case the formatter above is not the actual cause). Many Thanks!
  • Posted 25 August 2026, 5:57 am EST

    Hi,

    We reviewed the custom LET formatter you shared. Based on our investigation, the custom formatter itself is not responsible for converting 2026 into an OADate.

    The key factor is the existing date formatter cached in the cell’s style:

    “formatCached”: “yyyy/m/d”

    Why the conversion occurs

    When 2026 is copied as plain text from Notepad and pasted into the target cell, SpreadJS processes the pasted value based on the formatter associated with the destination cell.

    Since the destination cell has a date formatter (yyyy/m/d), the numeric text 2026 is interpreted as an OADate serial number. Therefore, the underlying value becomes a Date value and is serialized in the .sjs file as:

    “value”: “/OADate(2026)/”

    The LET formatter you provided is primarily responsible for formatting/displaying the cell value. There is no specific part of the formula that instructs SpreadJS to convert the incoming 2026 into an OADate.

    How formatCached is involved

    The formatCached entry is an internal cached representation of the formatter associated with the cell’s style. It is used to avoid repeatedly parsing the formatter during processing/rendering.

    For example, the following code is sufficient to reproduce the behavior:

    var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
    var sheet = spread.getSheet(0);
    
    // Apply a date formatter to the cell
    sheet.getCell(0, 0).formatter("yyyy/m/d");

    After saving the workbook as an .sjs file and inspecting style.json, you can find the corresponding formatter information.

    If you then paste the plain text 2026 from Notepad into that cell, the value is interpreted according to the date formatter and becomes an OADate value.

    The date formatter can also be introduced through other operations, such as:

    Applying a date format directly using the API.

    Applying a date format through the Format Cells dialog in Designer.

    Importing an Excel or SJS file containing date-formatted cells.

    Copying formatting from another date-formatted cell.

    Applying a date formatter at the row, column, or sheet default-style level, which can then be inherited by the cell.

    Therefore, if the yyyy/m/d formatter was not intentionally assigned to this cell, we recommend checking whether it is being inherited from a row, column, or sheet-level style.

    Recommended approach

    If the target cell is intended to contain numeric values, you can reset its formatter to General:

    sheet.setFormatter(row, col, “General”);

    You can also check the row, column, and sheet-level styles to ensure that a date formatter is not being inherited.

    In summary, the custom LET formatter is not the cause of the OADate conversion. The conversion is driven by the date formatter associated with the destination cell’s style, which is reflected by the formatCached: “yyyy/m/d” entry.

    We hope this clarifies the relationship between the custom formatter, the cached formatter, and the OADate conversion.

    If you are still facing the issue or feel that your questions have not been fully addressed, please share the file with us so that we can investigate it further.

    If the file contains confidential or sensitive information, please replace it with dummy data while keeping the same structure and behavior, and then share the modified file with us.

    Regards,

    Priyam

  • Posted 26 August 2026, 3:30 am EST

    It’s very helpful! Thank you!

Need extra support?

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

Learn More

Forum Channels