Skip to main content

Пакет для работы с .docx файлами

Project description

DocxP

DocxP — это мой небольшой Python-проект для создания и форматирования Word-документов с использованием библиотеки python-docx. Вы можете дополнять и расширять ее при необходимости. Я постарался построить гибкую основу для последующего расширения.

Возможности

  • Абстрактные классы для описания стилей документа, абзацев и текста.
  • Реализация базовых стилей и логики генерации Word-документов.
  • Гибкая настройка шрифтов, отступов, выравнивания и др.

Структура проекта

  • core/ — модуль с основными и абстрактными классами:
    • AbstractClasses.py — абстрактные интерфейсы
    • CoreClasses.py — реализация базовых стилей
    • CustomClasses.py — расширение с пользовательскими стилями

Установка

pip install python-docx py_docx_creator

Пример использования

from py_docx_creator.CoreClasses import CoreDocumentCreator
from py_docx_creator.CustomClasses import MainPageFormat, MainDocumentWriter, HeaderParagraphFormat, MainTextStyle, \
    MainParagraphFormat


class DocumentAPI(CoreDocumentCreator):

    def __init__(self, file_name: str):
        super().__init__()
        self.file_name = file_name

    def run(self):
        self.create_document(self.file_name)
        MainPageFormat().apply_style(document=self.document)
        paragraph = MainDocumentWriter.add_paragraph_to_document(self.document)
        HeaderParagraphFormat().apply_style(paragraph=paragraph)
        run = MainDocumentWriter.add_run_to_paragraph(paragraph=paragraph, text="Какой либо текст")
        MainTextStyle().apply_style(run=run)

        paragraph = MainDocumentWriter.add_paragraph_to_document(self.document)
        MainParagraphFormat().apply_style(paragraph=paragraph)
        run = MainDocumentWriter.add_run_to_paragraph(paragraph=paragraph, text="Какой либо текст")
        MainTextStyle().apply_style(run=run)
        self.save_document()


if __name__ == '__main__':
    
    DocumentAPI("Документ.docx").run()

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

py_docx_creator-0.1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

py_docx_creator-0.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file py_docx_creator-0.1.1.tar.gz.

File metadata

  • Download URL: py_docx_creator-0.1.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for py_docx_creator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9d6453882a1723d0e2a4bb123d59880228245c0fab55beee5f0d9fbe7389720b
MD5 e20e0a6d24e06f1e5c6f93e73e37c477
BLAKE2b-256 5d9ca407542a0be58f0eae5b116221f80964cb649d8b9d5d90c8e537f0e53cf8

See more details on using hashes here.

File details

Details for the file py_docx_creator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_docx_creator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f081d712022a5062286e703e61fb29ce072d68c65b6dc2e3019ac53daf15f3fd
MD5 860ad6b83279737d6ce4d0c0cb870cad
BLAKE2b-256 427990c8075429b48644270580390758ea09738901c8d6ded0f4477d0f4fe935

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