• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python document_builder.DocxBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pydocx.test.document_builder.DocxBuilder的典型用法代码示例。如果您正苦于以下问题:Python DocxBuilder类的具体用法?Python DocxBuilder怎么用?Python DocxBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DocxBuilder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_xml

    def get_xml(self):
        li_text = [
            ('AAA', 0, 1),
            ('BBB', 1, 1),
            ('CCC', 2, 1),
            ('DDD', 2, 1),
            ('EEE', 1, 1),
            ('FFF', 2, 1),
            ('GGG', 2, 1),
            ('HHH', 1, 1),
            ('III', 2, 1),
            ('JJJ', 2, 1),
            ('KKK', 0, 1),
            ('LLL', 0, 2),
            ('MMM', 1, 2),
            ('NNN', 1, 2),
            ('OOO', 0, 2),
            ('PPP', 1, 2),
            ('QQQ', 1, 2),
            ('RRR', 2, 2),
            ('SSS', 0, 2),
            ('TTT', 1, 2),
            ('UUU', 1, 2),
        ]
        lis = b''
        for text, ilvl, numId in li_text:
            lis += DXB.li(text=text, ilvl=ilvl, numId=numId)

        xml = DXB.xml(lis)
        return xml
开发者ID:AndrewSallans,项目名称:pydocx,代码行数:30,代码来源:test_xml.py


示例2: get_xml

    def get_xml(self):
        li_text = [
            ('AAA', 0, 2),
            # Because AAA and CCC are part of the same list (same list id)
            # and BBB is different, these need to be split into three
            # lists (or lose everything from BBB and after.
            ('BBB', 0, 1),
            ('CCC', 0, 2),
        ]
        lis = b''
        for text, ilvl, numId in li_text:
            lis += DXB.li(text=text, ilvl=ilvl, numId=numId)

        xml = DXB.xml(lis)
        return xml
开发者ID:OmniaSolutions,项目名称:pydocx,代码行数:15,代码来源:test_xml.py


示例3: get_xml

    def get_xml(self):
        tags = [
            DXB.li(text='AAA', ilvl=0, numId=2),
            # Because AAA and DDD are part of the same list (same list id)
            # and BBB,CCC are different, these need to be properly formatted
            # into a single list where BBB,CCC are added as nested list to AAA item
            DXB.li(text='BBB', ilvl=0, numId=1),
            DXB.li(text='CCC', ilvl=0, numId=1),
            DXB.li(text='DDD', ilvl=0, numId=2),
        ]
        body = b''
        for el in tags:
            body += el

        xml = DXB.xml(body)
        return xml
开发者ID:CenterForOpenScience,项目名称:pydocx,代码行数:16,代码来源:test_xml.py


示例4: load_document

    def load_document(self):
        # It's likely that we could replace this logic with a
        # WordprocessingDocumentFactory
        document = WordprocessingDocument(path=None)
        package = document.package
        document_part = package.create_part(uri="/word/document.xml")

        if self.numbering_dict is not None:
            numbering_xml = DXB.numbering(self.numbering_dict)
            self.relationships.append(
                {
                    "external": False,
                    "target_path": "numbering.xml",
                    "data": numbering_xml,
                    "relationship_id": "numbering",
                    "relationship_type": NumberingDefinitionsPart.relationship_type,  # noqa
                }
            )

        if self.styles_xml:
            self.relationships.append(
                {
                    "external": False,
                    "target_path": "styles.xml",
                    "data": self.styles_xml,
                    "relationship_id": "styles",
                    "relationship_type": StyleDefinitionsPart.relationship_type,
                }
            )

        for relationship in self.relationships:
            target_mode = "Internal"
            if relationship["external"]:
                target_mode = "External"
            target_uri = relationship["target_path"]
            if "data" in relationship:
                full_target_uri = posixpath.join(package.uri, "word", target_uri)
                package.streams[full_target_uri] = BytesIO(relationship["data"])
                package.create_part(uri=full_target_uri)
            document_part.create_relationship(
                target_uri=target_uri,
                target_mode=target_mode,
                relationship_type=relationship["relationship_type"],
                relationship_id=relationship["relationship_id"],
            )

        package.streams[document_part.uri] = BytesIO(self.document_xml)
        package.create_relationship(
            target_uri=document_part.uri, target_mode="Internal", relationship_type=MainDocumentPart.relationship_type
        )

        # This is the standard page width for a word document (in points), Also
        # the page width that we are looking for in the test.
        self._page_width = 612

        return document
开发者ID:botzill,项目名称:pydocx,代码行数:56,代码来源:utils.py



注:本文中的pydocx.test.document_builder.DocxBuilder类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.WordprocessingDocumentFactory类代码示例发布时间:2022-05-25
下一篇:
Python parser.Parser类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap