# -*- coding: utf-8 -*-
import logging
import os,sys
sys.path.append(os.path.abspath(os.path.join(os.getcwd(), "..")))
import pandas as pd
logging.basicConfig(filename='myprogramlog.txt', level=logging.DEBUG,
format='%(asctime)s-%(levelname)s - %(message)s') #导入日志模块
# logging.disable(logging.CRITICAL) #禁止日志输出
from moudlescript.dataserver import DataServer
mServer = DataServer(server='127.0.0.1',user='sa',password='',database='')
sql = "select * from ywdj"
df = mServer.readSql(sql)
# delsql = "delete from ywdj where CLFS=''"
# mServer.delSql(delsql)
df.CLFS = df.CLFS.str.replace(' ','')
df['CLFS']['**']='**'
df.CJZ = df.CJZ.str.replace(' ','')
tables = pd.crosstab(df.CJZ,df.CLFS,margins=False)
tables.index.name='处理人'
tables.reset_index(inplace=True)
tables.columns.name='处理人'
styles = [
dict(selector="th", props=[("font-size", "150%"),
("text-align", "center"),
("border", "1px solid black"),
('background-color','gray'),
('width','100px')
]),
dict(selector="tr", props=[("font-size", "100%"),
("text-align", "center"),
("border", "1px solid black"),
('width','100px')
]),
dict(selector="td", props=[("font-size", "100%"),
("text-align", "center"),
("border", "1px solid black"),
('width','100px')
]),
dict(selector="caption", props=[("font-size", "80%"),
("color", "blue"),
("text-align", "left"),
("caption-side", "bottom")])
]
tables.columns=[['表格标题','表格标题','表格标题','表格标题','表格标题'],['处理人', '办理', '办结', '转派', '退单']]
tables = tables.style.hide_index().set_table_styles(styles)\
.bar(subset=[('表格标题','办结')],color='green',vmin=40,vmax=200)\
.set_caption("表格下标").set_properties()
import dataframe_image as dfi
dfi.export(tables,'aa.png')
最后一个单元格格式
dict(selector="tbody tr:last-child td:last-child", props=[
('background','#ffffff'),
])
网友评论