为美化openpyxl表格,特设置样式,把有关参数与大家分享fromopenpyxl import load_workbookfromopenpyxl import Workbookfromopenpyxl.worksheet.table import Table, TableStyleInfo
wb=Workbook()
ws=wb.active
data=[
['Apples', 10000, 5000, 8000, 6000],
['Pears', 2000, 3000, 4000, 5000],
['Bananas', 6000, 6000, 6500, 6000],
['Oranges', 500, 300, 200, 700],
]
ws.append(["Fruit", "2011", "2012", "2013", "2014"])for row indata:
ws.append(row)
tab= Table(displayName="Table1", ref="A1:E5") #名称管理器 如E超出数据范围出错:warn("File may not be readable: column headings must be strings.")
#'TableStyleLight11' 1-21 还有此样式 "TableStyleMedium9" 1-28 TableStyleDark1 1-11# showFirstColumn=True,
# showLastColumn=True, showRowStripes=