学习自《python编程快速上手——让繁琐的工作自动化》
其中一些方法和属性以改为新版的表达
挖坑待填(书中库太老……代码都不可用,有空更新)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| import openpyxl
wb = openpyxl.load_workbook('example.xlsx')
wb.sheetnames
sheet = wb[sheetname]
sheet.title
wb.active
sheet['A1'] sheet['A1'].value sheet.cell(row = 1, column = 2)
c = sheet['A1'] c.row c.column c.coordinates
sheet.max_row sheet.max_column sheet.min_row sheet.min_column
openpyxl.cell.column_index_from_string() openpyxl.cell.get_column_letter()
tuple(sheet['A1':'C3']) sheet.columns[1] sheet.rows[1]
wb = openpyxl.Workbook() wb.save()
wb.create_sheet(index, title) wb.remove(sheet)
from openpyxl.styles import Font, Style
italic24Font = Font(size = 24, italic = True) styleObj = Style(font = italic24Font) sheet['A1'].style = styleObj
|