Skip to main content

Merging data (XLSX, JSON) and template (DOCX) into resulting DOCX document

Project description

http://d2d.penta.by/#Tutorial

Usage

import

import q2data2docx.q2data2docx

merge local files

d2d = q2data2docx.q2data2docx.q2data2docx()
d2d.loadJsonFile("your-file-name.json")  # JSON data file
# or
d2d.loadJsonFile("your-file-name.xlsx")  # XLSX data file

d2d.loadDocxFile("your-file-name.docx")  # DOCX template file
if d2d.merge():
    d2d.saveFile("result")

if d2d.merge():
    d2d.saveFile("result")

or

q2data2docx.q2data2docx.merge("your-file-name.docx", "your-file-name.json", "result")
# or
q2data2docx.q2data2docx.merge("your-file-name.docx", "your-file-name.xlsx", "result")

merge data from memory

d2d = q2data2docx.q2data2docx.q2data2docx()

d2d.setJsonBinary(open("your-file-name.json", "rb").read())
# or
d2d.setXlsxBinary(open("your-file-name.xlsx", "rb").read())

d2d.setDocxTemplateBinary(open("your-file-name.docx", "rb").read())
if d2d.merge():
    d2d.saveFile("result")

or

d2d = q2data2docx.q2data2docx.q2data2docx(
    docxTemplateBinary=open("your-file-name.docx", "rb").read(),
    jsonBinary=open("your-file-name.json", "rb").read(),
)
# or 
d2d = q2data2docx.q2data2docx.q2data2docx(
    docxTemplateBinary=open("your-file-name.docx", "rb").read(),
    xlsxBinary=open("your-file-name.xlsx", "rb").read(),
)
if d2d.merge():
    d2d.saveFile("result")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

q2data2docx-0.1.29.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

q2data2docx-0.1.29-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file q2data2docx-0.1.29.tar.gz.

File metadata

  • Download URL: q2data2docx-0.1.29.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.11.7 Windows/10

File hashes

Hashes for q2data2docx-0.1.29.tar.gz
Algorithm Hash digest
SHA256 80a159640a88a069d3739dd2db6b77c28e98a07b89c77ecc72bd716b1fa51850
MD5 8c7ae2ac4f9eeeb49857fa7ab7c945bf
BLAKE2b-256 8873442709d2379e0e0c8d450e99d3c18d1e5fa2da532295b28e8554181dcfdd

See more details on using hashes here.

File details

Details for the file q2data2docx-0.1.29-py3-none-any.whl.

File metadata

  • Download URL: q2data2docx-0.1.29-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.11.7 Windows/10

File hashes

Hashes for q2data2docx-0.1.29-py3-none-any.whl
Algorithm Hash digest
SHA256 dc20fef83ddf05c159acc88aaf22234b0254daa9191774865a13f05b14b2bc4a
MD5 1f0d85dcba352f8eabfb90c323086fe6
BLAKE2b-256 1d67ab4f6eff421b41a934798bb5002d25b0105409fe1c0ec31c8bff17335a0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page