Skip to content

aras72h/docx_report_templater

Repository files navigation

Docx Templater with PizZip

This Node.js script uses PizZip and Docxtemplater to load a .docx file, populate it with dynamic data, and generate a new .docx document based on the provided template and data.

Features

  • Loads a .docx file from the filesystem.
  • Fills the template with dynamic data.
  • Supports Persian (Farsi) date and string formatting.
  • Exports the modified document as a new .docx file.

Requirements

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/repo-name.git
    cd repo-name
  2. Install the dependencies:

    npm install

Usage

  1. Place your template file (input.docx) in the root directory.

  2. Modify the data in the dataObject as needed. This object contains all the values that will be replaced in the template.

  3. Run the script:

    node script.js
  4. The new document will be generated as output.docx in the same directory.

Dynamic Data Example

Here is an example of the data populated into the template:

{
  "NetworkAreaName": "معاونت صدا",
  "NetworkName": "شبکه جوان (صدا)",
  "ReleaseDate": "2024-01-15",
  "content": "بیان مطلب بی اساس مجری...",
  "SupervisorFullName": "آمنه سادات احمدی",
  "start": "22:11:32",
  "end": "22:12:33"
}

The script also:

  • Converts Gregorian dates to Persian (Farsi).
  • Removes seconds and milliseconds from time strings.

Output

A new .docx file, output.docx, will be generated with the populated data.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published