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.15.tar.gz (12.3 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.15-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: q2data2docx-0.1.15.tar.gz
  • Upload date:
  • Size: 12.3 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.15.tar.gz
Algorithm Hash digest
SHA256 0647bb006f5b89a8a1c187d83a6d8c3545eb71f58b7cf031ee57afd93618f302
MD5 6af2c7c71dd971afacf84efbec8c3c41
BLAKE2b-256 a59aa32834618871bd5ee1f7af06b3a23eb3776c7795363f4d57150ba4d99915

See more details on using hashes here.

File details

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

File metadata

  • Download URL: q2data2docx-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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.15-py3-none-any.whl
Algorithm Hash digest
SHA256 350e1f2a9247c90d2250dc926d1245ae6f0bd4e21a9ef97c09f7269739a92411
MD5 0ca3efc4f863bafc72f1ad4b017e7158
BLAKE2b-256 a5156ec986d97d2b1cf45b8d0c158f3798d71be4eb95a466c782d7da21ac2a5b

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