Как в BAS работать с документами MS Word ?

Поддержка
  • Подскажите, Как в BAS работать с документами MS Word (добавлять записи, редактировать, удалять файл и проч.)?
    Прочитал, вроде есть модуль node-office для этого, но не могу его поставить, выходит какая то ошибка.node_log.txt
    Может есть еще какие то способы работы с ворд документами в БАС по аналогии с эксел файлами?

  • Нашел хороший модуль для ворд документов docxtemplater, который установился в БАС. В документации есть код проверки работы модуля. Запустил это код в БАС, выходит такая ошибка: CUSTOM~LOG[-][red][440454553] [03:47:40] Поток №1 : Error: Cannot find module 'pizzip'
    Require stack:

    • F:\BrowserAutomationStudio\apps\25.4.1\e\0f88.K9tW\distr\app\lib\custom\bg2knumc9p.js
    • F:\BrowserAutomationStudio\apps\25.4.1\e\0f88.K9tW\distr\app\lib\internal\custom.js
    • F:\BrowserAutomationStudio\apps\25.4.1\e\0f88.K9tW\distr\app\lib\main.js
      Не может найти модуль pizzip. Скачал архив всего модуля, там этот файл есть. Подскажите, в какую папку в БАС нужно положить файл pizzip, чтобы БАС его увидел?
      Код такой:
      const PizZip = require("pizzip");
      const Docxtemplater = require("docxtemplater");

    const fs = require("fs");
    const path = require("path");

    // Load the docx file as binary content
    const content = fs.readFileSync(
    path.resolve(__dirname, "input.docx"),
    "binary"
    );

    const zip = new PizZip(content);

    const doc = new Docxtemplater(zip, {
    paragraphLoop: true,
    linebreaks: true,
    });

    // Render the document (Replace {first_name} by John, {last_name} by Doe, ...)
    doc.render({
    first_name: "John",
    last_name: "Doe",
    phone: "0652455478",
    description: "New Website",
    });

    const buf = doc.getZip().generate({
    type: "nodebuffer",
    // compression: DEFLATE adds a compression step.
    // For a 50MB output document, expect 500ms additional CPU time
    compression: "DEFLATE",
    });

    // buf is a nodejs Buffer, you can either write it to a
    // file or res.send it with express for example.
    fs.writeFileSync(path.resolve(__dirname, "output.docx"), buf);