Search & Replace Texts in DOCX

satyajitnayak

satyajit nayak

Posted on June 9, 2024

Search & Replace Texts in DOCX

Search & Replace Texts in DOCX

Hey guys, I have created a package name edit-office-file which can search & replace multiple text strings inside a DOCX file as well other office files.

  1. First install the pkg: npm i edit-office-files.

  2. Usage style:




import {SearchAndReplace} from 'edit-office-files';

async function main() {
  const searchTexts = ['Hello World', 'are You', 'coloured'];
  const replacementTexts = ['REPLACEMENT1', 'REPLACEMENT2', 'REPLACEMENT3'];
  const reader = new SearchAndReplace('assets/document.docx', searchTexts, replacementTexts, 'updated.docx');
  await reader.process();
}

main();



Enter fullscreen mode Exit fullscreen mode

Here is the github link for the project.

💖 💪 🙅 🚩
satyajitnayak
satyajit nayak

Posted on June 9, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Search & Replace Texts in DOCX
javascript Search & Replace Texts in DOCX

June 9, 2024