利用xlsxwriter对象来对Dataframe 或者 Excel对象作格式化处理:
- 相关案例1 相关案例2
- 代码:
dfs = pd.read_excel('1015全市依申请政务服务指标.xls', sheet_name='汇总')writer = pd.ExcelWriter('123.xlsx', 'xlsxwriter')dfs.to_excel(writer, sheet_name='Sheet1')bookObj = writer.bookwriterObj = writer.book.sheetnames['Sheet1']formatObj = bookObj.add_format({'num_format': '0.00%'})writerObj.set_column('I:I', cell_format=formatObj)writerObj.set_column('J:J', cell_format=formatObj)writer.save()
