import openpyxl
from openpyxl.worksheet.cell_range import CellRange
from openpyxl.styles import Alignment
# 打开工作簿
workbook = openpyxl.load_workbook('秘书学评分标准陈嘉丽.xlsx')
# 选择活动工作表
worksheet = workbook.active
# 调整列宽
column = 'A' # 要调整的列
worksheet.column_dimensions["A"].width = 10
cell = worksheet['A2']
cell.value = cell.value.strip()
# 设置文字居中
cell.alignment = Alignment(horizontal='center', vertical='center')
# 保存工作簿
workbook.save("adjusted_column_width.xlsx")
openpyxl 将EXCEL调整至一页
最新推荐文章于 2024-08-13 11:55:13 发布