Word
Word
The Word module is responsible for performing handling actions on files created in Word. Its methods can be accessed as in the example below:
js
const fillError = await Documents.Word.fillWordTemplate["v2_0_0"]({
outputPath: "C:/Users/Roberty/Documents/",
fileName: "teste.docx",
templatePath: "C:/Users/Roberty/Documents/testeTemplate.docx",
data: {
name: "Roberty",
phone: "123-456-7890",
email: "roberty@roberty.app"
}
})
Methods
fillWordTemplate
Method responsible for filling in the variables of a dynamic Word template.
js
const fillError = await Documents.Word.fillWordTemplate["v2_0_0"]({
outputPath: "C:/Users/Roberty/Documents/",
fileName: "teste.docx",
templatePath: "C:/Users/Roberty/Documents/testeTemplate.docx",
data: {
name: "Roberty",
phone: "123-456-7890",
email: "roberty@roberty.app"
}
})
Required parameters
outputPath: String - expects the path of the file that will be filled in.fileName: String - expects the name of the file that will be filled in.templatePath: String - expects the path of the template that will be filled in. The path must contain the file name and the extension.
Optional parameters
data: Object - expects an object with the variables that will be filled in the template. The object keys must be the names of the template variables defined between double braces (e.g.{{name}}).
Return
The constant or variable created, such as the fillError of the example shown earlier, receives a value of the Object type that gives access to the following properties:
fillError.error: string - returns an error message if the filling is not performed successfully.