构造字典写入excel文件

it2022-05-05  196

import xlsxwriter

workbook = xlsxwriter.Workbook('./ttt.xlsx') worksheet = workbook.add_worksheet() bold_format = workbook.add_format({'bold': True}) # worksheet.set_column(0,0,8) # worksheet.set_column(1,3,36) # worksheet.set_column(4,4,8) # worksheet.set_column(5,9,25)

worksheet.write('A1', '公司代码', bold_format) worksheet.write('B1', '公司名称', bold_format) worksheet.write('C1', '银行科目代码', bold_format) worksheet.write('D1', '开户行名称', bold_format) worksheet.write('E1', '置业银行余额调节表余额', bold_format) worksheet.write('F1', '资金平台系统余额', bold_format) worksheet.write('G1', '核对结果', bold_format)

row = 1 col = 0#expense是字典 for item in (expenses): # 使用write_string方法,指定数据格式写入数据 worksheet.write_string(row, col, item['accCode']) worksheet.write_string(row, col + 1, item['cmName']) worksheet.write_string(row, col + 2, item['bankCode']) worksheet.write_string(row, col + 3, item['bankOfdeposit']) worksheet.write_string(row, col + 4, '1') worksheet.write_string(row, col + 5, item['fundbalance']) worksheet.write_string(row, col + 6, '正确')

row += 1 workbook.close()

转载于:https://www.cnblogs.com/jessitommy/p/11077203.html

相关资源:DirectX修复工具V4.0增强版

最新回复(0)