OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
675 stars 95 forks source link

xlsx file places with insertWorksheetsFromBase64 but returns error #3179

Closed A-Glazer closed 5 months ago

A-Glazer commented 1 year ago

Provide required information needed to triage your issue

Your Environment

Expected behavior

When inserting an xlsx file on Excel Web, no error should appear if the file was inserted correctly.

Current behavior

I have an xlsx file that I would like to insert into my current Excel document via Office Online. The file places properly using insertWorksheetsFromBase64, but then fails with this error:

RichApi.Error: There was an internal error while processing the request.
    at new n (excel-web-16.00.js:25:314248)
    at i.processRequestExecutorResponseMessage (excel-web-16.00.js:25:378414)
    at excel-web-16.00.js:25:376477

Note that the xlsx file inserts properly in both Desktop and Web, yet on Web it returns an error when it should complete.

Steps to reproduce

  1. Open an xlsx file in Excel Online
  2. Try inserting an xlsx file with multiple tabs using insertWorksheetsFromBase64
  3. Note the error message
  4. Check your document, you will see the correct tabs have been inserted

Link to live example(s)




Provide additional details

Here is the code:

let options = {
   sheetNamesToInsert: [],
   positionType: 'After',
   relativeTo: "Sheet1" 
}
Excel.run(async (context) => {
  context.workbook.insertWorksheetsFromBase64(base64,options);
  await context.sync();
}

Context

Useful logs

Console error:

RichApi.Error: There was an internal error while processing the request.
    at new n (excel-web-16.00.js:25:314248)
    at i.processRequestExecutorResponseMessage (excel-web-16.00.js:25:378414)
    at excel-web-16.00.js:25:376477

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

ghost commented 1 year ago

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

donlvMSFT commented 1 year ago

Hi @A-Glazer , I want to confirm that the same call would success on Win32 but fail on Excel online? Is it possible to share your base64 to us for further investigation?

A-Glazer commented 1 year ago

After doing more research, this appears to only happen if there is a hidden tab in the xlsx file being placed. The tabs are inserted properly (including the hidden one), but an error message appears. This issue only appears in the Web version. When I insert the same file in Windows desktop, it inserts properly with no error.

donlvMSFT commented 1 year ago

Hi @A-Glazer , we tried several ways to repro this, with hidden tabs, but still could not hit your case. Could you share more information for us to narrow down this issue?

A-Glazer commented 1 year ago

Here is the document that isn't working to place in Excel Web. (It places in Desktop). The tabs are inserted properly but a RichApi error also appears.

(RichApi.Error: There was an internal error while processing the request.
    at new n (excel-web-16.00.js:25:314248)
    at i.processRequestExecutorResponseMessage (excel-web-16.00.js:25:378414)
    at excel-web-16.00.js:25:376477)

Hidden page.xlsx

donlvMSFT commented 1 year ago

Hi @A-Glazer , we found that in the hidden sheet there're some #REF! in the formulas. After remove these formulas, the function works well. Could you double check the formulas?

A-Glazer commented 1 year ago

Thank you for looking into this issue. I removed the chart from the last tab, but it still isn't inserting properly. The main issue is that the spreadsheet displays an error AND inserts properly. Either an error should be displayed OR it should insert properly. I have this issue in many different types of Excel spreadsheets (with different tables, charts, images, hidden tabs etc.). Is there a way to determine if the spreadsheet you are inserting contains a sheet that is not supported? How can we avoid both inserting AND displaying an error?

donlvMSFT commented 1 year ago

Could you also check the formulas as I mentioned before? And thanks for the advice, currently as base64 is complex to check, there's not a direct way to give detail suggestions...

A-Glazer commented 1 year ago

Removing the #REF! in the formulas fixed this specific issue, so the issue is with the #REF!, not the hidden sheet. Is there a way to check if the spreadsheet being inserted contains any unsupported formulas/tables etc.? I want to avoid displaying the RichApi error AND inserting properly.

donlvMSFT commented 1 year ago

Thanks @A-Glazer for the confirmation. Currently the API lack of the ability to check the supported scenario, but we'll follow up on this.

ZYUN-MSFT commented 1 year ago

Hi @A-Glazer, the API insertWorksheetsFromBase64 will copy things from the base64 encoded Excel file.

Currently in Excel Online, the unsupported floating features are Comment, Slicer, Chart and PivotTable.\ For in-cell content, API will follow Excel Online's Cut-Copy-Paste Policy.

Because the complex #REF! scenario break Excel Online's Copy logic (direct copy from the Web UI will break the Excel Online), so the API throw the error too. We are investing this with Excel Online Team to solve this problem internal.

Thanks.

ghost commented 1 year ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

A-Glazer commented 1 year ago

Okay, thank you.

XuanZhouMSFT commented 5 months ago

Thanks for reporting this issue. After careful consideration, our team has decided to not fix this issue in the short term. We recommend you to upvote or submit a new Tech Community New Ideas item, this will give us visibility of the commonality of it and will help with our prioritization. If we end up working on this issue, we will re-activate as needed.