对齐、字体、列宽等单元格的设定,图和代码如下:
-*- encoding: utf-8 -*
import pymysql
import openpyxl
import time
import datetime
from openpyxl.styles import Border, Side, Font,Alignment,PatternFill
#取系统时间,用于保存更新日期
check_date = datetime.datetime.now().strftime("%Y-%m-%d")
#打开MySQL数据库连接
db = pymysql.connect("localhost", "root", "root", "STUDY", charset="utf8")
cursor = db.cursor()
#打开excel
wb = openpyxl.Workbook()
ws_test = wb.active
ws_test.title = "statis"
#查询Mysql数据库中的数据
sql_export = "SELECT\
date(is_date) as statis_date,\
word,\
SUBSTRING_INDEX(word_c,';',2),\
word_type,\
case \
when is_able = 0 then '错误' \
when is_able = 1 then &#