亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

Python辦公自動化

離島 全棧工程師
難度入門
時長 3小時44分
學習人數
綜合評分8.93
16人評價 查看評價
9.2 內容實用
9.2 簡潔易懂
8.4 邏輯清晰
  • Py chrome常用快捷鍵大全


    620e35f6000116bc09600540.jpg620e36810001d23009600540.jpg
    620e36af0001879209600540.jpg
    ——————《Python辦公自動化》
    查看全部
    1 采集 收起 來源:PyCharm的使用

    2022-02-17

  • # 添加表格

    table = slide.shapes.add_table(2, 3, Inches(2), Inches(2), Inches(4), Inches(2)).table

    # 填充內容

    table.cell(0, 0).text = 'title1'

    table.cell(0, 1).text = 'title2'

    table.cell(0, 2).text = 'title3'

    # 合并單元格

    cell = table.cell(0, 0)

    cell1 = table.cell(0, 2)

    cell.merge(cell1)

    # 取消合并單元格

    if cell.is_merge_origin:

    ????cell.split()

    查看全部
    0 采集 收起 來源:寫入表格到PPT

    2022-01-18

  • from pptx.util import Inches, Pt

    from pptx.enum.shapes import MSO_SHAPE

    from pptx.dml.color import RGBColor

    # 添加自選圖形

    shape = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, Inches(2), Inches(2), Inches(5), Inches(3))

    # 設置填充色、邊框樣式

    fill = shape.fill

    fill.solid()

    fill.fore_color.rgb = RGBColor(255, 0, 0)

    line = shape.line

    line.color.rgb = RGBColor(55, 3, 5)

    line.width = Pt(2)

    查看全部
    0 采集 收起 來源:添加圖形到PPT

    2022-01-18

  • import pptx

    from pptx.util import Inches


    # 得到演示文稿的對象

    prs = pptx.Presentation()

    # 打開ppt

    # prs = pptx.Presentation('test.pptx')


    # 指定模板,插入一張幻燈片

    slide = prs.slides.add_slide(prs.slide_layouts[0])

    prs.slides.add_slide(prs.slide_layouts[1])

    prs.slides.add_slide(prs.slide_layouts[2])


    # 刪除幻燈片

    del prs.slides._sldIdLst[1]


    # 向幻燈片中插入文本框

    text1 = slide.shapes.add_textbox(Inches(5), Inches(5), Inches(5), Inches(5))

    text1.text = '我是文本框'

    p1 = text1.text_frame.add_paragraph()

    p1.text = '我是段落1'

    p1.add_run().text = 'end'


    # 向幻燈片中現有的元素寫入文本

    title_shape = slide.shapes.title

    title_shape.text = '標題1'

    slide.shapes.placeholders[1].text = '標題2'


    # 保存ppt文檔

    prs.save('test.pptx')

    查看全部
    0 采集 收起 來源:寫入文本到PPT

    2022-01-17

  • pip install python-pptx

    import pptx

    查看全部
  • pip install pywin32

    from win32com.client import constants, gencache

    import os


    def createpdf(wordPath, pdfPath):

    ????word = gencache.EnsureDispatch('Word.Application'

    ????doc = word.Documents.Open(wordPath, ReadOnly=1)

    ????# 轉換方法

    ????doc.ExportAsFixedFormat(pdfPath, constants.wdExportFormatPDF)

    ????word.Quit()


    # 單個文件轉換

    createpdf('info.docx', 'info.pdf')


    # 多個文件轉換

    os.listdir('.') # 獲取當前文件夾下的所有文件

    wordfiles = []????# 存儲當前文件夾下的所有word文件

    for file in os.listdir('.'):

    ????if file.endswith(('.doc', '.docx')):

    ????????wordfiles.append(file)

    for file in wordfiles:

    ????filepath = os.path.abspath(file)????# 獲取文件的絕對路徑

    ????index = filepath.rindex('.') # 獲取最后一個點的索引

    ????pdfpath = filepath[:index] + '.pdf' # 構造pdf絕對路徑

    ????createpdf(filepath, pdfpath)

    查看全部
    0 采集 收起 來源:Word轉換PDF

    2022-01-11

    • from docx.enum.style import WD_STYLE_TYPE # 導入

    • style = document.styles.add_style('textstyle', WD_STYLE_TYPE.PARAGRAPH) # 創建段落樣式

    • style.font.size = Pt(5) # 設置字體大小

    • p1 = document.add_paragraph('texttexttext', style='textstyle') # 為段落設置樣式

    • 官方文檔:https://python-docx.readthedocs.io/en/latest/user/styles-using.html

    • 樣式對照表:http://www.thedoctools.com/index.php?show=mt_create_style_name_list

    • http://img1.sycdn.imooc.com//61dc111400015dea08940490.jpg

    • table = document.add_table(rows=1, cols=3, style='Medium List 1') # 為表格設置內置樣式

    • document.styles['textstyle'].delete() # 刪除樣式

    查看全部
    0 采集 收起 來源:Word樣式處理

    2022-01-10

    • document.add_picture('logo.jpg') # 插入圖片

    • document.add_picture('logo.jpg', Pt(20), Pt(30)) # 插入圖片,設置寬高

    • table = document.add_table(rows=1, cols=2) # 插入表格

    • header_cells = table.rows[0].cells # 獲取第一行的單元格

    • header_cells[0].text = 'title' # 向表格中寫入內容

    • rows.cells = table.add_row().cells # 添加行

    • len(document.tables[0].rows) # 獲取文檔中第一個表格的總行數

    • document.tables[0].cell(0, 1).text # 獲取文檔中第一個表格的第一行第二列的內容

    查看全部
    • from docx import Document

    • from docx.shared import Pt, RGBColor

    • document = Document() # 創建文檔對象

    • document = Document("info.docx") # 讀取現有word,創建文檔對象

    • document.add_heading('title') # 寫入標題,默認標題1樣式

    • document.add_heading('title', level=4) # 指定標題級別

    • p1 = document.add_paragraph('xxxxxxxxxxxxxxxxx') # 寫入段落

    • p1.insert_paragraph_before('xxxxxxxxxx') # 在段落前插入段落

    • format = p1.paragraph_format # 獲取段落的樣式

    • format.left_indent = Pt(20) # 左側縮進

    • format.right_indent = Pt(20) # 右側縮進

    • format.first_line_indent = Pt(20) # 首行縮進

    • format.line_spacing = 1.5 # 1.5倍行間距

    • run = p1.add_run('xxxxxxxxxx') # 在段落后追加文字

    • run.font.size = Pt(12) # 設置字號

    • run.font.name =?'微軟雅黑' # 設置字體

    • run.font.color.rgb = RGBColor(235, 33, 24) # 設置文字顏色

    • run.bold = True # 設置加粗

    • run.font.underline = True # 添加下劃線

    • run.font.italic = True # 設置斜體

    • document.save('test.docx') # 保存文檔

    查看全部
    1 采集 收起 來源:寫入文本到Word

    2022-01-06

  • python-docx

    查看全部
  • 查看全部
    • style = xlwt.XFStyle() # 初始化樣式


    • font = xlwt.Font() # 初始化字體

    • font.name = "宋體" # 字體名稱

    • font.bold = True # 加粗

    • font.height = 11 * 20 # 字號設置為11,20為衡量單位

    • font.colour_index = 0x08 # 字體顏色設置為黑色,也可等于索引1

    • style.font = font # 設置字體


    • align = xlwt.Alignment() # 初始化對齊方式

    • align.horz = 0x02 # 設置水平方向居中對齊

    • align.vert = 0x01 # 設置垂直方向居中對齊

    • style.alignment = align # 設置對齊方式


    • borders = xlwt.Borders() # 初始化邊框

    • borders.right = xlwt.Borders.DASHED # 右邊框設置為虛線

    • borders.bottom = xlwt.Borders.DOTTED # 下邊框設置為點線

    • style.borders = borders # 設置邊框樣式


    • bgcolor = xlwt.Pattern() # 初始化顏色模式

    • bgcolor.pattern = xlwt.Pattern.SOLID_PATTERN # 顏色模式設置為背景顏色

    • bgcolor.pattern_fore_colour = 22 # 背景顏色設置為灰色

    • style.pattern = bgcolor # 設置背景顏色


    • ws.write(0, 0, value, style) # 設置單元格樣式

    查看全部
    0 采集 收起 來源:寫入格式化

    2021-12-28

    • import xlwt # 導入模塊,只支持xls格式

    • wb = xlwt.Wortbook() # 創建工作簿

    • ws = wb.add_sheet("sheet1") # 創建sheet

    • ws.write_merge(0, 1, 0, 5, "title") # 合并單元格,并寫入數據

    • ws.write(i + 2, j, value) # 向單元格寫入數據

    • ws.insert_bimap("文件路徑.bmp", 0, 1) # 插入圖片

    • wb. save("保存文件路徑.xls") # 保存工作簿

    查看全部
    0 采集 收起 來源:xlwt寫入Excel

    2021-12-27

  • pip install xlrd

    查看全部
    0 采集 收起 來源:xlrd常用函數

    2021-11-27

    1. 使用pycharm

    2. pycharm常用配置

    3. ctrl+shift+F10 運行

    4. 文件和代碼片段? #author:username #createdate:${DATE}

    查看全部
    0 采集 收起 來源:PyCharm的使用

    2021-11-08

舉報

0/150
提交
取消
課程須知
有python語法基礎,缺少完整項目開發經驗,為找工作增加經驗而學習
老師告訴你能學到什么?
學好辦公自動化,走遍天下都不怕。本課程會講解如何巧妙充分的利用python強大的第三方辦公文件庫。利用python高效的開發辦公自動化之Office。實現Excel自動化,Word自動化,PPT自動化。

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!