Share via

Web Excel Unable to import base64 but working with Excel Desktop

Aakash Gautam 0 Reputation points
2026-01-07T05:57:38.5566667+00:00

Only issue with Web excel in import using office.js but working with Excel Desktop
const workbook = context.workbook;
const base64 =""
workbook.insertWorksheetsFromBase64(base64, { positionType: Excel.WorksheetPositionType.end, }); await context.sync();
console.log("All sheets deleted and replaced with a blank sheet"); });

Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments

1 answer

Sort by: Most helpful
  1. Michelle-N 15,545 Reputation points Microsoft External Staff Moderator
    2026-01-07T09:31:41.0366667+00:00

    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.

    User's image 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.

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.