pythonopenpyxl笔记
from openpyxl import Workbook wb = Workbook() ws = wb.active ''' 指定sheet wb.create_sheet("mySheet") ws = wb.get_sheet_by_name("mySheet") ''' i = 1 j = 1 for val in headers: ws.cell(row=i,column=j,value=val) j = j + 1 i = 2 for row in data_lines: j = 1 for val in row: ws.cell(row=i,column=j,value=val) j = j + 1 i = i + 1 ### 冻结窗口,单元格上面的行和左边的列将会冻结(单元格所在的行和列不会被冻结) # 冻结第一行 ws.freeze_panes = ws['A2'] # 冻结第一列 ws.freeze_panes = ws['B1'] # 冻结第一行第一列 ws.freeze_panes = ws['B2'] wb.save(expfile)
网页标题:pythonopenpyxl笔记
文章位置:http://pwwzsj.com/article/pescgc.html