Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when renaming a sheet and adding rows via Excel.js #4998

Open
buzzo123 opened this issue Oct 22, 2024 · 2 comments
Open

Error when renaming a sheet and adding rows via Excel.js #4998

buzzo123 opened this issue Oct 22, 2024 · 2 comments
Assignees
Labels
Area: Excel Issue related to Excel add-ins Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown

Comments

@buzzo123
Copy link

Description:
I am encountering an error when trying to rename a sheet in Excel while also adding rows to a table using the Excel JS library. The error occurs when renaming the sheet is initiated but not completed, and rows are added programmatically.

Environment:

  • Excel version: Microsoft® Excel® for Microsoft 365 MSO (Version 2409 Build 16.0.18025.20030) 64-bit
  • Office.js version: "@microsoft/office-js": "^1.1.94"
  • Platform: Windows 11

Steps to Reproduce:

  1. Attempt to rename a sheet.
  2. While the sheet is in renaming mode, run the following script:
async function createTable() {
  await Excel.run(async (context) => {
    context.workbook.worksheets.getItemOrNullObject("Sample").delete();
    const sheet = context.workbook.worksheets.add("Sample");

    const expensesTable = sheet.tables.add("A1:D1", true /*hasHeaders*/);
    expensesTable.name = "ExpensesTable";

    expensesTable.getHeaderRowRange().values = [["Date", "Merchant", "Category", "Amount"]];

    const rows = [["1/1/2017", "The Phone Company", "Communications", "$120"]];
    expensesTable.rows.add(undefined, rows);
    sheet.activate();
    await context.sync();
  });
}
  1. Observe the following error in the console:

Error Log:

[ERROR]: Error:
{
    "stack": "RichApi.Error: There was an internal error while processing the request.\n    at new n (https://appsforoffice.microsoft.com/lib/1/hosted/excel-win32-16.01.js:25:265694)\n    at n.processRequestExecutorResponseMessage (https://appsforoffice.microsoft.com/lib/1/hosted/excel-win32-16.01.js:25:330663)\n    at https://appsforoffice.microsoft.com/lib/1/hosted/excel-win32-16.01.js:25:328724",
    "message": "There was an internal error while processing the request.",
    "name": "RichApi.Error",
    "code": "GeneralException",
    "traceMessages": [],
    "innerError": null,
    "debugInfo": {
        "code": "GeneralException",
        "message": "There was an internal error while processing the request.",
        "errorLocation": "Worksheet.delete",
        "statement": "itemOrNullObject.delete();",
        "surroundingStatements": [
            "var workbook = context.workbook;",
            "var worksheets = workbook.worksheets;",
            "var itemOrNullObject = worksheets.getItemOrNullObject(...);",
            "// >>>>>",
            "itemOrNullObject.delete();",
            "// <<<<<",
            "var add = worksheets.add(...);",
            "var tables = add.tables;",
            "var add1 = tables.add(...);",
            "add1.name = ...;",
            "var headerRowRange = add1.getHeaderRowRange();",
            "..."
        ],
        "fullStatements": [
            "Please enable config.extendedErrorLogging to see full statements."
        ]
    },
    "httpStatusCode": 500
}

Expected Result:
The table rows should be added without any errors.

Actual Result:
An internal error occurs, causing the process to fail when attempting to delete and recreate the worksheet, breaking the row addition logic.

Additional Information:
This error is not expected in our workflow and disrupts the code execution. Any assistance in identifying the root cause and resolving this issue would be greatly appreciated.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Area: Excel Issue related to Excel add-ins label Oct 22, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: attention 👋 Waiting on Microsoft to provide feedback label Oct 22, 2024
Copy link
Contributor

Thank you for letting us know about this issue. We will take a look shortly. Thanks.

@qinliuMSFT
Copy link
Member

Thank you for reporting this issue, I can repro it. It has been put on our backlog #9472329 , the team will investigate and we will reply to you as soon as there is any progress. Thank you for your patience.

@qinliuMSFT qinliuMSFT added Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Excel Issue related to Excel add-ins Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown
Projects
None yet
Development

No branches or pull requests

2 participants