十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
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)