OfficeDev / office-js-docs-pr

Microsoft Office Add-ins Documentation
https://learn.microsoft.com/office/dev/add-ins
Creative Commons Attribution 4.0 International
404 stars 250 forks source link

How to get the current Word data in the base64 form #4518

Closed RishiKumar156 closed 6 months ago

RishiKumar156 commented 7 months ago

Hi devs, Sorry for this issue I've been trying to implement this method for the past fews weeks, But there are no standar way to implement a method where it can get all the data from the current word doc as base64, I'm using React add-ins

Package.json { "name": "office-addin-taskpane-react-js", "version": "0.0.1", "repository": { "type": "git", "url": "https://github.com/OfficeDev/Office-Addin-TaskPane-React-JS.git" }, "license": "MIT", "config": { "app_to_debug": "word", "app_type_to_debug": "desktop", "dev_server_port": 3000 }, "scripts": { "build": "webpack --mode production", "build:dev": "webpack --mode development", "dev-server": "webpack serve --mode development", "lint": "office-addin-lint check", "lint:fix": "office-addin-lint fix", "prettier": "office-addin-lint prettier", "start": "office-addin-debugging start manifest.xml", "start:desktop": "office-addin-debugging start manifest.xml desktop", "start:web": "office-addin-debugging start manifest.xml web", "stop": "office-addin-debugging stop manifest.xml", "validate": "office-addin-manifest validate manifest.xml", "watch": "webpack --mode development --watch" }, "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.0", "@fluentui/react-components": "^9.30.4", "@fluentui/react-icons": "^2.0.214", "@material-ui/core": "^4.12.4", "@mui/material": "^5.15.12", "@mui/styled-engine-sc": "^6.0.0-alpha.17", "axios": "^1.6.7", "core-js": "^3.9.1", "dotenv": "^16.4.5", "es6-promise": "^4.2.8", "framer-motion": "^11.0.12", "jspdf": "^2.5.1", "lucide-react": "^0.354.0", "multiselect-react-dropdown": "^2.0.25", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.51.0", "react-select": "^5.8.0", "regenerator-runtime": "^0.13.7", "styled-components": "^6.1.8" }, "devDependencies": { "@babel/core": "^7.13.10", "@babel/plugin-transform-class-properties": "^7.3.0", "@babel/preset-env": "^7.6.3", "@babel/preset-react": "^7.6.3", "@babel/preset-typescript": "^7.13.0", "@types/es6-collections": "^0.5.29", "@types/office-js": "^1.0.256", "@types/office-runtime": "^1.0.23", "@types/react": "^18.2.21", "@types/react-dom": "^18.2.7", "@types/webpack": "^4.4.34", "acorn": "^8.5.0", "babel-loader": "^8.2.2", "babel-polyfill": "^6.26.0", "copy-webpack-plugin": "^9.0.1", "eslint-plugin-office-addins": "^2.1.5", "eslint-plugin-react": "^7.28.0", "file-loader": "^6.2.0", "find-process": "^1.4.4", "html-loader": "^4.1.0", "html-webpack-plugin": "^5.5.0", "less": "^3.10.3", "less-loader": "^10.0.1", "office-addin-cli": "^1.5.5", "office-addin-debugging": "^5.0.12", "office-addin-dev-certs": "^1.11.3", "office-addin-lint": "^2.2.5", "office-addin-manifest": "^1.12.3", "office-addin-prettier-config": "^1.2.0", "os-browserify": "^0.3.0", "process": "^0.11.10", "source-map-loader": "^3.0.0", "ts-loader": "^9.4.1", "typescript": "^4.7.4", "webpack": "^5.76.3", "webpack-cli": "^5.0.1", "webpack-dev-server": "4.13.1" }, "prettier": "office-addin-prettier-config", "browserslist": [ "ie 11" ] }

AlexJerabek commented 7 months ago

Hi @RishiKumar156,

Thank you for reaching out. Have you tried using the Document.insertFileFromBase64 method? That should get the contents of a Word doc (that's been parsed into a base64-encoded string) and insert it into your current document. You can see this workflow in action in the Import templates in a Word document sample.

Please let me know if that helps. Assigning @ElizabethSamuel-MSFT to follow up.

RishiKumar156 commented 2 months ago

Hi @RishiKumar156,

Thank you for reaching out. Have you tried using the Document.insertFileFromBase64 method? That should get the contents of a Word doc (that's been parsed into a base64-encoded string) and insert it into your current document. You can see this workflow in action in the Import templates in a Word document sample.

Please let me know if that helps. Assigning @ElizabethSamuel-MSFT to follow up.

Hi it was from my end I have resolved it, thank you for the reference.

RishiKumar156 commented 2 months ago

Hi, I'm having trouble implementing react-router-dom in my project. Despite multiple attempts, I've been unable to succeed. Can you help me tackle this issue?

AlexJerabek commented 2 months ago

Hi @RishiKumar156,

For react questions, I'd recommend asking on Stack Overflow, using both the "office-js" and "react" tags. Stack is the best place to get help with these intersections of technology.

RishiKumar156 commented 2 months ago

Hi @RishiKumar156,

For react questions, I'd recommend asking on Stack Overflow, using both the "office-js" and "react" tags. Stack is the best place to get help with these intersections of technology.

thank you for the heads up, But I got the problem sorted out. Not to mention that I have reaised a question long time ago at stack overflow, But I got zero response, well it's all fine now thank you :)