An Office service that supports add-ins to interact with objects in Office client applications.
Hi @Aakash Gautam
Thank you for posting your question in the Microsoft Q&A forum.
Based on the information you described, I understand that importing worksheets from Base64 using Office.js works in Excel Desktop but fails in Excel on the web, even though the same API (insertWorksheetsFromBase64) is being used.
After reviewing related documentation and known limitations, here are a few important points to consider:
Although workbook.insertWorksheetsFromBase64() is supported in Excel on the web, it does not support source worksheets that contain certain elements, such as PivotTables, Charts, Comments, or Slicers. If any of these objects are present in the source file, the method will fail when running in Excel Web.
In the code snippet you shared, the
base64 value is an empty string (""), which will always cause an error. This API requires a valid Base64-encoded Excel (.xlsx) file.
In Excel Desktop, passing a valid Base64 string typically works as expected. In Excel on the web, even with a valid Base64 string, failures can still occur if the Base64 value is not formatted correctly. For example, Excel Web expects a raw Base64 string only, not a Data URL (such as data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,...).
To help troubleshoot further, could you please let me know:
-Do you see a specific error message in the browser console?
-Are there any PivotTables, Charts, Comments, or Slicers in the source workbook?
-How is the Base64 string being generated and passed into the API?
If you can share more details or the exact console error message, I’ll be happy to help investigate further.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.