1.1.0 • Published 7 months ago
docfillx v1.1.0
Install the package
- install the library via npm:
npm install docfillx
- Import the handleFile function In your JavaScript/TypeScript file, import the handleFile function from the package:
import { handleFile } from 'docfillx';
Place your Word template in the public folder Ensure your Word template file (.docx) is available in the public folder of your project.
Prepare the data Create an object that holds the data you want to insert into the Word template.
const dataValue = {
name: "John Doe",
age: 30,
data: [
{ id: 1, name: "a" },
{ id: 2, name: "b" },
],
};
- Call the handleFile function Pass the Word template file and your data object as arguments to the handleFile function:
handleFile("template.docx", dataValue);
- Download the processed file The library will replace placeholders in the Word template with the provided data and trigger a download of the updated file.