# -*- coding: utf-8 -*-
"""
Created on Tue Jun 21 08:00:50 2022
"""
from openpyxl.styles import Font,Border,Side
import os
#from openpyxl.utils.cell import get_column_letter
import openpyxl
pth = r'\Python\compress'
name = 'Copy.xlsx'
file = os.path.join(pth,name)
wb = openpyxl.load_workbook(file)
#wb.active.column_dimensions
#wb.active.row_dimensions
wb.sheetnames
#sheets = wb.sheetnames
#for sheet in sheets:
## wb[sheet].row_dimensions[2].height = 20
# wb[sheet].column_dimensions['C'].width = 50
# wb[sheet].column_dimensions['C'].width = 50
# wb[sheet].column_dimensions['C'].width = 50
# wb[sheet].column_dimensions['C'].width = 50
# wb[sheet].column_dimensions['C'].width = 50
# wb[sheet].column_dimensions['C'].width = 50
# wb[sheet].column_dimensions['C'].width = 50
ws = wb['报送清单']
fontStyle = Font(size = "8")
fontStyle2 = Font(size = "8",bold=True)
border = Border(left=Side(style='thin'),bottom=Side(style='thin'),right=Side(style='thin'),top=Side(style='thin'))
maxRows = ws.max_row
maxColumns = ws.max_column
for i in range(1,maxColumns+1):
# print(ws[get_column_letter(i+1)])
# print(i)
for k in range(1,maxRows+1):
# print(k)
# print(get_column_letter(i+1))
# cell = str(ws[get_column_letter(i+1)+str(k+1)].value)
cell = ws.cell(row = k,column=i)
# print(cell)
cell1 = ws.cell(row = 1,column=i)
cell3 = ws.cell(row = 3,column=i)
cell.font = fontStyle
cell1.font = fontStyle2
cell3.font = fontStyle2
cell.border = border
ws.column_dimensions['A'].width = 3
ws.column_dimensions['B'].width = 16
ws.column_dimensions['C'].width = 31
ws.column_dimensions['D'].width = 14
ws.column_dimensions['E'].width = 4.55
ws.column_dimensions['F'].width = 9
ws.column_dimensions['G'].width = 3.36
newname = '调整格式后区域other方法.xlsx'
newefile = os.path.join(pth,newname)
wb.save(newefile)
wb.close()