python-docx

Reads, queries and modifies Microsoft Word 2007/2008 docx files.

  • 所有者: mikemaccana/python-docx
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

###########
This Project Has Moved!
###########

Python DocX is now part of Python OpenXML. There's all kinds of new stuff, including Python 3 support, sister libraries for doing Excel files, and more. Check out the current Python DocX GitHub <https://github.com/python-openxml/python-docx>_ and the current Python DocX docs <https://python-docx.readthedocs.org/en/latest/>_.

Info below is kept for archival purposes. Go use the new stuff!

Introduction

The docx module creates, reads and writes Microsoft Office Word 2007 docx
files.

These are referred to as 'WordML', 'Office Open XML' and 'Open XML' by
Microsoft.

These documents can be opened in Microsoft Office 2007 / 2010, Microsoft Mac
Office 2008, Google Docs, OpenOffice.org 3, and Apple iWork 08.

They also validate as well formed XML <http://validator.w3.org/check>_.

The module was created when I was looking for a Python support for MS Word
.docx files, but could only find various hacks involving COM automation,
calling .Net or Java, or automating OpenOffice or MS Office.

The docx module has the following features:

Making documents

Features for making documents include:

  • Paragraphs
  • Bullets
  • Numbered lists
  • Document properties (author, company, etc)
  • Multiple levels of headings
  • Tables
  • Section and page breaks
  • Images

.. image:: http://github.com/mikemaccana/python-docx/raw/master/screenshot.png

Editing documents

Thanks to the awesomeness of the lxml module, we can:

  • Search and replace
  • Extract plain text of document
  • Add and delete items anywhere within the document
  • Change document properties
  • Run xpath queries against particular locations in the document - useful for
    retrieving data from user-completed templates.

Getting started

Making and Modifying Documents

  • Just download python docx <http://github.com/mikemaccana/python-docx/tarball/master>_.

  • Use pip or easy_install to fetch the lxml and PIL modules.

  • Then run::

    example-makedocument.py

Congratulations, you just made and then modified a Word document!

Extracting Text from a Document

If you just want to extract the text from a Word file, run::

example-extracttext.py 'Some word file.docx' 'new file.txt'

Ideas & To Do List


- Further improvements to image handling
- Document health checks
- Egg
- Markdown conversion support


We love forks, changes and pull requests!
  • Check out the HACKING to add your own changes!
  • For this project on github
  • Send a pull request via github and we'll add your changes!

Want to talk? Need help?


Email python-docx@googlegroups.com


License
~~~~~~~

Licensed under the `MIT license <http://www.opensource.org/licenses/mit-license.php>`_

Short version: this code is copyrighted to me (Mike MacCana), I give you
permission to do what you want with it except remove my name from the credits.
See the LICENSE file for specific terms.

主要指標

概覽
名稱與所有者mikemaccana/python-docx
主編程語言Python
編程語言Python (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2009-12-27 18:10:13
推送於2015-09-04 12:17:15
最后一次提交2014-08-19 13:50:35
發布數1
最新版本名稱v0.2.0 (發布於 2013-03-07 17:47:22)
第一版名稱v0.2.0 (發布於 2013-03-07 17:47:22)
用户参与
星數1.1k
關注者數163
派生數349
提交數180
已啟用問題?
問題數0
打開的問題數0
拉請求數8
打開的拉請求數6
關閉的拉請求數18
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?