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

TypeError: context.document.insertFileFromBase64 is not a function #2137

Open
MeeGooBoo opened this issue Nov 18, 2024 · 4 comments
Open

TypeError: context.document.insertFileFromBase64 is not a function #2137

MeeGooBoo opened this issue Nov 18, 2024 · 4 comments
Assignees
Labels
Area: Word Feedback on Word content Needs: attention 👋 Waiting on Microsoft to provide feedback

Comments

@MeeGooBoo
Copy link

MeeGooBoo commented Nov 18, 2024

context.document.body.insertFileFromBase64(templateBase64, "Replace");//This is fine, but information like headers is not preserved

context.document.insertFileFromBase64(templateBase64, "Replace");//TypeError: context.document.insertFileFromBase64 is not a function |npm> "name": "@microsoft/office-js","version": "1.1.95"

Please let us know which version I support context. Document.InsertFileFromBase64?Or is there another way to preserve the headers and all styles of the template file??
image

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 new issue, needs PM on rotation to triage asap label Nov 18, 2024
@AlexJerabek
Copy link
Contributor

Hi @MJSQ,

Document.insertFileFromBase64 is part of requirement set WordApi 1.5. You can see which versions of Word support this API in this table: https://learn.microsoft.com/javascript/api/requirement-sets/word/word-api-requirement-sets?view=word-js-preview#requirement-set-availability. What version of Word are you seeing this error in? If it is covered according to the file, we can transfer this issue to the product team.

Also, you should reference office.js through our CDN: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/referencing-the-javascript-api-for-office-library-from-its-cdn?view=word-js-preview. That ensures your add-in always has the latest version of office.js.

@AlexJerabek AlexJerabek added Area: Word Feedback on Word content Needs: author feedback Waiting for author (creator) of Issue to provide more info and removed Needs: triage 🔍 new issue, needs PM on rotation to triage asap labels Nov 18, 2024
@ElizabethSamuel-MSFT
Copy link
Contributor

@MJSQ Also note that the office-js NPM package isn't the recommended path for Office.js (see the "Support" section of the @microsoft/office-js package readme).

@MeeGooBoo
Copy link
Author

您好 ,

Document.insertFileFromBase64是要求集 WordApi 1.5 的一部分。您可以在下表中查看哪些版本的 Word 支持此 API:https://learn.microsoft.com/javascript/api/requirement-sets/word/word-api-requirement-sets?view=word-js-preview#requirement-set-availability。您在哪个版本的 Word 中看到此错误?如果根据文件覆盖,我们可以将此问题转给产品组。

此外,您应该通过我们的 CDN:https://learn.microsoft.com/en-us/office/dev/add-ins/develop/referencing-the-javascript-api-for-office-library-from-its-cdn?view=word-js-preview 引用office.js。这可确保您的外接程序始终具有最新版本的 office.js。

Thanks for your reply. It has been fixed in word-win32-16.01.js version.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Nov 19, 2024
@MeeGooBoo
Copy link
Author

MeeGooBoo commented Nov 19, 2024

@MJSQ Also note that the office-js NPM package isn't the recommended path for Office.js (see the "Support" section of the @microsoft/office-js package readme).

Download via NPM package in the use of The context.document.insertFileFromBase64 causes problems, by replacing the word-win32-16.01.js and office.js to fix the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Word Feedback on Word content Needs: attention 👋 Waiting on Microsoft to provide feedback
Projects
None yet
Development

No branches or pull requests

3 participants