zoukankan      html  css  js  c++  java
  • python-docx about unusual operating

    from docx import Document
    document = Document
    table = document.add_table(rows=2, cols=3)
    #
    set the whole table in the center position table.alignment = WD_TABLE_ALIGNMENT.CENTER
    # set every single cell center 
    for row in table.rows: row.height = Inches(1) for cell in row.cells:
               # set colums center cell.vertical_alignment
    = WD_CELL_VERTICAL_ALIGNMENT.CENTER paragraphs = cell.paragraphs for paragraph in paragraphs:
                   # set each cell center paragraph.paragraph_format.alignment
    = WD_PARAGRAPH_ALIGNMENT.CENTER for run in paragraph.runs: font = run.font font.size = Pt(22)
    row_cell = table.add_row().cells
    # choice one row row_pic
    = row_cell[0]
    # clear blank area row_pic._tc.clear_content()
    # use paragraph function pic_run
    = row_pic.add_paragraph().add_run()
    # insert a picture path as a str into a cell from a table pic_run.add_picture(
    './picture/{}'.format("picture_name.jpg"), width=Inches(5))

    one way to change the font size from paragraph:

     p = document.add_paragraph()
     # there is not just set current paragraph font size ,also set the
     #  whole word enter blank,which means every enter as size as
     # there font size. if the other paragraph set font size as this
     # way, they will change together and you should care about that.
     p.style.font.size = Pt(22)

    the other way :

      run = p.add_run(u'hello world')
      # there is another way set font size ,different from upton ,only
      # set current paragraph,the key is function ==>app_run() after it.
      run.font.size = Pt(22)
  • 相关阅读:
    手写PE文件(不借助编译器,用十六进制数进行编写)
    浅谈代码段加密原理(防止静态分析)
    PE文件动态加载执行过程
    静态数据连接库(.lib)和动态连接库(.dll)
    关于普通断点/内存断点/硬件断点
    x64dbg零基础使用教程
    HOOK相关原理与例子
    socket,实现服务器和客户端对话
    解析PE文件
    python正则表达式---基于re模块
  • 原文地址:https://www.cnblogs.com/2012-dream/p/10899549.html
Copyright © 2011-2022 走看看