python-docx の API リファレンス
python-docx (python-openxml/python-docx) の公開 API 224 件 —— クラス 106、関数 9、メソッド 109。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。
リポジトリ: python-openxml/python-docx
| 種別 | 件数 |
|---|---|
| クラス | 106 |
| 関数 | 9 |
| メソッド | 109 |
API 一覧
class
src.docx.blkcntnr.BlockItemContainerBase class for proxy objects that can contain block items.
class
src.docx.comments.CommentProxy for a single comment in the document.
method
src.docx.comments.Comment.author() -> strRead/write.
method
src.docx.comments.Comment.comment_id() -> intThe unique identifier of this comment.
method
src.docx.comments.Comment.initials() -> str | NoneRead/write.
method
src.docx.comments.Comment.text() -> strThe text content of this comment as a string.
method
src.docx.comments.Comment.timestamp() -> dt.datetime | NoneThe date and time this comment was authored.
class
src.docx.comments.CommentsCollection containing the comments added to this document.
method
src.docx.comments.Comments.add_comment(text:str='', author:str='', initials:str | None='') -> CommentAdd a new comment to the document and return it.
method
src.docx.comments.Comments.get(comment_id:int) -> Comment | NoneReturn the comment identified by `comment_id`, or |None| if not found.
class
src.docx.document.DocumentWordprocessingML (WML) document.
method
src.docx.document.Document.part() -> DocumentPartThe |DocumentPart| object of this document.
method
src.docx.document.Document.save(path_or_stream:str | IO[bytes])Save this document to `path_or_stream`.
class
src.docx.drawing.DrawingContainer for a DrawingML object.
method
src.docx.drawing.Drawing.has_picture() -> boolTrue when `drawing` contains an embedded picture.
class
src.docx.enum.base.BaseEnumBase class for Enums that do not map XML attr values.
class
src.docx.enum.base.BaseXmlEnumBase class for Enums that also map XML attr values.
class
src.docx.enum.base.DocsPageFormatterGenerate an .rst doc page for an enumeration.
class
src.docx.enum.dml.MSO_COLOR_TYPESpecifies the color specification scheme.
class
src.docx.enum.shape.WD_INLINE_SHAPE_TYPECorresponds to WdInlineShapeType enumeration.
class
src.docx.enum.table.WD_TABLE_ALIGNMENTSpecifies table justification type.
class
src.docx.enum.text.WD_BREAK_TYPECorresponds to WdBreakType enumeration.
class
src.docx.enum.text.WD_COLOR_INDEXSpecifies a standard preset color to apply.
class
src.docx.enum.text.WD_TAB_ALIGNMENTSpecifies the tab stop alignment to apply.
class
src.docx.exceptions.PythonDocxErrorGeneric error class.
class
src.docx.image.bmp.BmpImage header parser for BMP images.
class
src.docx.image.constants.JPEG_MARKER_CODEJPEG marker codes.
class
src.docx.image.constants.MIME_TYPEImage content types.
class
src.docx.image.constants.PNG_CHUNK_TYPEPNG chunk type names.
class
src.docx.image.constants.TIFF_FLD_TYPETag codes for TIFF Image File Directory (IFD) entries.
class
src.docx.image.constants.TIFF_TAGTag codes for TIFF Image File Directory (IFD) entries.
class
src.docx.image.exceptions.InvalidImageStreamErrorThe recognized image stream appears to be corrupted.
class
src.docx.image.exceptions.UnrecognizedImageErrorThe provided image stream could not be recognized.
class
src.docx.image.gif.GifImage header parser for GIF images.
method
src.docx.image.helpers.StreamReader.read(count)Allow pass-through read() call.
method
src.docx.image.helpers.StreamReader.tell()Allow pass-through tell() call.
class
src.docx.image.image.BaseImageHeaderBase class for image header subclasses like |Jpeg| and |Tiff|.
method
src.docx.image.image.BaseImageHeader.default_ext() -> strDefault filename extension for images of this type.
method
src.docx.image.image.Image.blob()The bytes of the image 'file'.
method
src.docx.image.image.Image.content_type() -> strMIME content type for this image, e.g.
method
src.docx.image.image.Image.ext()The file extension for the image.
method
src.docx.image.image.Image.horz_dpi() -> intInteger dots per inch for the width of this image.
method
src.docx.image.image.Image.px_height() -> intThe vertical pixel dimension of the image.
method
src.docx.image.image.Image.px_width() -> intThe horizontal pixel dimension of the image.
method
src.docx.image.image.Image.sha1()SHA1 hash digest of the image blob.
method
src.docx.image.image.Image.vert_dpi() -> intInteger dots per inch for the height of this image.
class
src.docx.image.jpeg.ExifImage header parser for Exif image format.
class
src.docx.image.jpeg.JfifImage header parser for JFIF image format.
class
src.docx.image.jpeg.JpegBase class for JFIF and EXIF subclasses.
class
src.docx.image.png.PngImage header parser for PNG images.
class
src.docx.image.tiff.TiffImage header parser for TIFF images.
class
src.docx.opc.constants.NAMESPACEConstant values for OPC XML namespaces.
class
src.docx.opc.constants.RELATIONSHIP_TARGET_MODEOpen XML relationship target modes.
class
src.docx.opc.exceptions.OpcErrorBase error class for python-opc.
method
src.docx.opc.oxml.CT_Relationships.new() -> CT_RelationshipsReturn a new ``<Relationships>`` element.
method
src.docx.opc.oxml.CT_Types.new()Return a new ``<Types>`` element.
func
src.docx.opc.oxml.parse_xml(text:str) -> etree._Element`etree.fromstring()` replacement that uses oxml parser.
func
src.docx.opc.oxml.serialize_for_reading(element:etree._Element) -> strSerialize `element` to human-readable XML suitable for tests.
class
src.docx.opc.package.OpcPackageMain API class for |python-opc|.
method
src.docx.opc.package.OpcPackage.save(pkg_file:str | IO[bytes])Save this package to `pkg_file`.
method
src.docx.opc.packuri.PackURI.ext() -> strThe extension portion of this pack URI, e.g.
class
src.docx.opc.part.PartBase class for package parts.
method
src.docx.opc.part.Part.blob() -> bytesContents of this package part as a sequence of bytes.
method
src.docx.opc.part.Part.content_type()Content type of this part.
method
src.docx.opc.part.Part.part_related_by(reltype:str) -> PartReturn part to which this part has a relationship of `reltype`.
method
src.docx.opc.part.Part.relate_to(target:Part | str, reltype:str, is_external:bool=False) -> strReturn rId key of relationship of `reltype` to `target`.
class
src.docx.opc.parts.coreprops.CorePropertiesPartCorresponds to part named ``/docProps/core.xml``.
class
src.docx.opc.phys_pkg.PhysPkgReaderFactory for physical package reader objects.
class
src.docx.opc.phys_pkg.PhysPkgWriterFactory for physical package writer objects.
method
src.docx.opc.rel.Relationships.add_relationship(reltype:str, target:Part | str, rId:str, is_external:bool=False) -> '_Relationship'Return a newly added |_Relationship| instance.
func
src.docx.opc.shared.cls_method_fn(cls:type, method_name:str)Return method of `cls` having `method_name`.
class
src.docx.oxml.comments.CT_Comment`w:comment` element, representing a single comment.
method
src.docx.oxml.coreprops.CT_CoreProperties.author_text() -> strThe text in the `dc:creator` child element.
method
src.docx.oxml.coreprops.CT_CoreProperties.new() -> CT_CorePropertiesReturn a new `<cp:coreProperties>` element.
method
src.docx.oxml.coreprops.CT_CoreProperties.revision_number() -> intInteger value of revision property.
class
src.docx.oxml.exceptions.XmlchemyErrorGeneric error class.
method
src.docx.oxml.ns.NamespacePrefixedTag.local_part() -> strThe local part of this tag.
method
src.docx.oxml.ns.NamespacePrefixedTag.nspfx() -> strThe namespace-prefix for this tag.
method
src.docx.oxml.ns.NamespacePrefixedTag.nsuri() -> strThe namespace URI for this tag.
func
src.docx.oxml.ns.nsdecls(*prefixes:str) -> strNamespace declaration including each namespace-prefix in `prefixes`.
func
src.docx.oxml.ns.nspfxmap(*nspfxs:str) -> Dict[str, str]Subset namespace-prefix mappings specified by *nspfxs*.
func
src.docx.oxml.ns.qn(tag:str) -> strStands for "qualified name".
func
src.docx.oxml.parser.parse_xml(xml:str | bytes) -> 'BaseOxmlElement'Root lxml element obtained by parsing XML character string `xml`.
class
src.docx.oxml.section.CT_HdrFtrRef`w:headerReference` and `w:footerReference` elements.
class
src.docx.oxml.section.CT_PageMar``<w:pgMar>`` element, defining page margins.
class
src.docx.oxml.settings.CT_Settings`w:settings` element, root element for the settings part.
class
src.docx.oxml.shape.CT_Anchor`<wp:anchor>` element, container for a "floating" shape.
class
src.docx.oxml.shape.CT_Inline`<wp:inline>` element, container for an inline shape.
class
src.docx.oxml.shape.CT_NonVisualDrawingPropsUsed for ``<wp:docPr>`` element, and perhaps others.
class
src.docx.oxml.shape.CT_Picture``<pic:pic>`` element, a DrawingML picture.
method
src.docx.oxml.shape.CT_Picture.new(pic_id:int, filename:str, rId:str, cx:Length, cy:Length) -> CT_PictureA new minimum viable `<pic:pic>` (picture) element.
class
src.docx.oxml.shape.CT_Point2DUsed for ``<a:off>`` element, and perhaps others.
class
src.docx.oxml.shared.CT_OnOffUsed for `w:b`, `w:i` elements and others.
class
src.docx.oxml.shared.CT_StringUsed for `w:pStyle` and `w:tblStyle` elements and others.
class
src.docx.oxml.simpletypes.BaseSimpleTypeBase class for simple-types.
class
src.docx.oxml.simpletypes.ST_HexColorAutoValue for `w:color/[@val="auto"] attribute setting.
class
src.docx.oxml.simpletypes.ST_HpsMeasureHalf-point measure, e.g.
class
src.docx.oxml.simpletypes.ST_MergeValid values for <w:xMerge val=""> attribute.
class
src.docx.oxml.simpletypes.ST_VerticalAlignRunValid values for `w:vertAlign/@val`.
class
src.docx.oxml.simpletypes.XsdAnyUriThere's a regex in the spec this is supposed to meet...
class
src.docx.oxml.simpletypes.XsdStringEnumerationSet of enumerated xsd:string values.
class
src.docx.oxml.simpletypes.XsdTokenXsd:string with whitespace collapsing, e.g.
class
src.docx.oxml.styles.CT_StyleA ``<w:style>`` element, representing a style definition.
class
src.docx.oxml.table.CT_Row``<w:tr>`` element.
method
src.docx.oxml.table.CT_Row.tc_at_grid_offset(grid_offset:int) -> CT_TcThe `tc` element in this tr at exact `grid offset`.
class
src.docx.oxml.table.CT_Tbl``<w:tbl>`` element.
class
src.docx.oxml.table.CT_TblGrid`w:tblGrid` element.
class
src.docx.oxml.table.CT_TblLayoutType`w:tblLayout` element.
class
src.docx.oxml.table.CT_TblPrEx`w:tblPrEx` element, exceptions to table-properties.
class
src.docx.oxml.table.CT_Tc`w:tc` table cell element.
method
src.docx.oxml.table.CT_Tc.grid_span() -> intThe integer number of columns this cell spans.
method
src.docx.oxml.table.CT_Tc.merge(other_tc:CT_Tc) -> CT_TcReturn top-left `w:tc` element of a new span.
method
src.docx.oxml.table.CT_Tc.top() -> intThe top-most row index in the vertical span of this cell.
class
src.docx.oxml.table.CT_TcPr``<w:tcPr>`` element, defining table cell properties.
method
src.docx.oxml.table.CT_TcPr.grid_span() -> intThe integer number of columns this cell spans.
class
src.docx.oxml.table.CT_TrPr``<w:trPr>`` element, defining table row properties.
class
src.docx.oxml.text.font.CT_Fonts`<w:rFonts>` element.
class
src.docx.oxml.text.font.CT_RPr`<w:rPr>` element, containing the properties for a run.
method
src.docx.oxml.text.font.CT_RPr.highlight_val() -> WD_COLOR_INDEX | NoneValue of `./w:highlight/@val`.
method
src.docx.oxml.text.font.CT_RPr.subscript() -> bool | None|True| if `./w:vertAlign/@w:val` is "subscript".
method
src.docx.oxml.text.font.CT_RPr.superscript() -> bool | None|True| if `w:vertAlign/@w:val` is 'superscript'.
method
src.docx.oxml.text.font.CT_RPr.sz_val() -> Length | NoneThe value of `w:sz/@w:val` or |None| if not present.
method
src.docx.oxml.text.font.CT_RPr.u_val() -> WD_UNDERLINE | NoneValue of `w:u/@val`, or None if not present.
method
src.docx.oxml.text.hyperlink.CT_Hyperlink.text() -> strThe textual content of this hyperlink.
class
src.docx.oxml.text.parfmt.CT_Ind``<w:ind>`` element, specifying paragraph indentation.
class
src.docx.oxml.text.parfmt.CT_Jc``<w:jc>`` element, specifying paragraph justification.
class
src.docx.oxml.text.parfmt.CT_TabStop`<w:tab>` element, representing an individual tab stop.
method
src.docx.oxml.text.run.CT_R.add_t(text:str) -> CT_TextReturn a newly added `<w:t>` element containing `text`.
method
src.docx.oxml.text.run.CT_R.text() -> strThe textual content of this run.
class
src.docx.oxml.xmlchemy.BaseAttributeBase class for OptionalAttribute and RequiredAttribute.
method
src.docx.oxml.xmlchemy.BaseAttribute.populate_class_members(element_cls:MetaOxmlElement, prop_name:str) -> NoneAdd the appropriate methods to `element_cls`.
class
src.docx.oxml.xmlchemy.BaseOxmlElementEffective base class for all custom element classes.
method
src.docx.oxml.xmlchemy.BaseOxmlElement.first_child_found_in(*tagnames:str) -> _Element | NoneFirst child with tag in `tagnames`, or None if not found.
method
src.docx.oxml.xmlchemy.BaseOxmlElement.remove_all(*tagnames:str) -> NoneRemove child elements with tagname (e.g.
method
src.docx.oxml.xmlchemy.BaseOxmlElement.xpath(xpath_str:str) -> AnyOverride of `lxml` _Element.xpath() method.
method
src.docx.oxml.xmlchemy.Choice.populate_class_members(element_cls:MetaOxmlElement, group_prop_name:str, successors:tuple[str, ...]) -> NoneAdd the appropriate methods to `element_cls`.
class
src.docx.oxml.xmlchemy.MetaOxmlElementMetaclass for BaseOxmlElement.
class
src.docx.oxml.xmlchemy.OneAndOnlyOneDefines a required child element for MetaOxmlElement.
method
src.docx.oxml.xmlchemy.OneAndOnlyOne.populate_class_members(element_cls:MetaOxmlElement, prop_name:str) -> NoneAdd the appropriate methods to `element_cls`.
method
src.docx.oxml.xmlchemy.OneOrMore.populate_class_members(element_cls:MetaOxmlElement, prop_name:str) -> NoneAdd the appropriate methods to `element_cls`.
class
src.docx.oxml.xmlchemy.RequiredAttributeDefines a required attribute on a custom element class.
method
src.docx.oxml.xmlchemy.ZeroOrMore.populate_class_members(element_cls:MetaOxmlElement, prop_name:str) -> NoneAdd the appropriate methods to `element_cls`.
class
src.docx.oxml.xmlchemy.ZeroOrOneDefines an optional child element for MetaOxmlElement.
method
src.docx.oxml.xmlchemy.ZeroOrOne.populate_class_members(element_cls:MetaOxmlElement, prop_name:str) -> NoneAdd the appropriate methods to `element_cls`.
class
src.docx.package.PackageCustomizations specific to a WordprocessingML package.
method
src.docx.package.Package.image_parts() -> ImageParts|ImageParts| collection object for this package.
class
src.docx.parts.comments.CommentsPartContainer part for comments added to the document.
class
src.docx.parts.hdrftr.FooterPartDefinition of a section footer.
method
src.docx.parts.hdrftr.FooterPart.new(package:Package)Return newly created footer part.
class
src.docx.parts.hdrftr.HeaderPartDefinition of a section header.
method
src.docx.parts.hdrftr.HeaderPart.new(package:Package)Return newly created header part.
class
src.docx.parts.image.ImagePartAn image part.
class
src.docx.parts.story.StoryPartBase class for story parts.
method
src.docx.parts.story.StoryPart.get_style(style_id:str | None, style_type:WD_STYLE_TYPE) -> BaseStyleReturn the style in this document matching `style_id`.
method
src.docx.parts.story.StoryPart.new_pic_inline(image_descriptor:str | IO[bytes], width:int | Length | None=None, height:int | Length | None=None) -> CT_InlineReturn a newly-created `w:inline` element.
method
src.docx.section.Section.bottom_margin() -> Length | NoneRead/write.
method
src.docx.section.Section.page_height() -> Length | NoneTotal page height used for this section.
method
src.docx.section.Section.page_width() -> Length | NoneTotal page width used for this section.
class
src.docx.settings.SettingsProvides access to document-level settings for a document.
class
src.docx.shared.CmConvenience constructor for length in centimeters, e.g.
class
src.docx.shared.ElementProxyBase class for lxml element proxy classes.
method
src.docx.shared.ElementProxy.part() -> XmlPartThe package part containing this object.
class
src.docx.shared.EmuConvenience constructor for length in English Metric Units, e.g.
class
src.docx.shared.InchesConvenience constructor for length in inches, e.g.
class
src.docx.shared.LengthBase class for length constructor classes Inches, Cm, Mm, Px, and Emu.
method
src.docx.shared.Length.pt()Floating point length in points.
class
src.docx.shared.MmConvenience constructor for length in millimeters, e.g.
class
src.docx.shared.PtConvenience value class for specifying a length in points.
class
src.docx.shared.RGBColorImmutable value object defining a particular RGB color.
class
src.docx.shared.StoryChildA document element within a story part.
method
src.docx.shared.StoryChild.part() -> StoryPartThe package part containing this object.
class
src.docx.shared.TwipsConvenience constructor for length in twips, e.g.
func
src.docx.shared.write_only_property(f:Callable[[Any, Any], None])@write_only_property decorator.
class
src.docx.styles.BabelFishTranslates special-case style names from UI name (e.g.
method
src.docx.styles.style.BaseStyle.builtin()Read-only.
method
src.docx.styles.style.BaseStyle.locked()Read/write Boolean.
method
src.docx.styles.style.BaseStyle.name()The UI name of this style.
method
src.docx.styles.style.BaseStyle.style_id() -> strThe unique key name (string) for this style.
class
src.docx.styles.style.CharacterStyleA character style.
class
src.docx.styles.style.ParagraphStyleA paragraph style.
class
src.docx.styles.styles.StylesProvides access to the styles defined in a document.
class
src.docx.table.TableProxy class for a WordprocessingML ``<w:tbl>`` element.
method
src.docx.table.Table.alignment() -> WD_TABLE_ALIGNMENT | NoneRead/write.
method
src.docx.table.Table.cell(row_idx:int, col_idx:int) -> _Cell|_Cell| at `row_idx`, `col_idx` intersection.
method
src.docx.table.Table.column_cells(column_idx:int) -> list[_Cell]Sequence of cells in the column at `column_idx` in this table.
method
src.docx.table.Table.row_cells(row_idx:int) -> list[_Cell]DEPRECATED: Use `table.rows[row_idx].cells` instead.
func
src.docx.table._Row.iter_tc_cells(tc:CT_Tc) -> Iterator[_Cell]Generate a cell object for each layout-grid cell in `tc`.
method
src.docx.text.font.Font.all_caps() -> bool | NoneRead/write.
method
src.docx.text.font.Font.bold() -> bool | NoneRead/write.
method
src.docx.text.font.Font.complex_script() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.cs_bold() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.cs_italic() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.double_strike() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.emboss() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.hidden() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.imprint() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.italic() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.math() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.name() -> str | NoneThe typeface name for this |Font|.
method
src.docx.text.font.Font.no_proof() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.outline() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.rtl() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.shadow() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.size() -> Length | NoneFont height in English Metric Units (EMU).
method
src.docx.text.font.Font.small_caps() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.snap_to_grid() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.spec_vanish() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.strike() -> bool | NoneRead/write tri-state value.
method
src.docx.text.font.Font.underline() -> bool | WD_UNDERLINE | NoneThe underline style for this |Font|.
method
src.docx.text.font.Font.web_hidden() -> bool | NoneRead/write tri-state value.
class
src.docx.text.hyperlink.HyperlinkProxy object wrapping a `<w:hyperlink>` element.
method
src.docx.text.hyperlink.Hyperlink.runs() -> list[Run]List of |Run| instances in this hyperlink.
class
src.docx.text.paragraph.ParagraphProxy object wrapping a `<w:p>` element.
method
src.docx.text.paragraph.Paragraph.rendered_page_breaks() -> List[RenderedPageBreak]All rendered page-breaks in this paragraph.
method
src.docx.text.paragraph.Paragraph.style() -> ParagraphStyle | NoneRead/Write.
method
src.docx.text.paragraph.Paragraph.text() -> strThe textual content of this paragraph.
class
src.docx.text.run.RunProxy object wrapping `<w:r>` element.
method
src.docx.text.run.Run.bold() -> bool | NoneRead/write tri-state value.
method
src.docx.text.run.Run.italic() -> bool | NoneRead/write tri-state value.
method
src.docx.text.run.Run.style() -> CharacterStyleRead/write.
method
src.docx.text.run.Run.underline() -> bool | WD_UNDERLINE | NoneThe underline style for this |Run|.
class
src.docx.text.tabstops.TabStopAn individual tab stop applying to a paragraph or style.
class
src.docx.types.ProvidesStoryPartAn object that provides access to the StoryPart.
class
src.docx.types.ProvidesXmlPartAn object that provides access to its XmlPart.
この情報について
掲載しているシグネチャは python-openxml/python-docx の公開ソースコードを
Python の ast モジュールで静的解析し、引数名・デフォルト値・
型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。
詳しくは仕組みの解説をご覧ください。