123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- import os
- import xml.etree.ElementTree as ET
- import xlwt
- import datetime
- import time
- import xlsxwriter
- import sys
- import socket
- import configparser
- def app_path():
- """Returns the base application path."""
- if hasattr(sys, 'frozen'):
-
- return os.path.dirname(sys.executable)
- return os.path.dirname(__file__)
- current_directory = os.path.dirname(os.path.abspath(__file__))
- tree = ET.parse(app_path() + '\\xml\\AuthCodeReport.xml')
- root = tree.getroot()
- fn = app_path() + '\\report\\授权码数据记录表' + '.xlsx'
- workbook = xlsxwriter.Workbook(fn)
- formatValue = workbook.add_format()
- formatValue.set_align('center')
- formatValue.set_font_name('等线')
- formatValueHead = workbook.add_format()
- formatValueHead.set_bold()
- formatValueHead.set_font_name('等线')
- formatHead = workbook.add_format()
- formatHead.set_font_size(20)
- formatHead.set_bold()
- formatHead.set_font_name('等线')
- sheetAuth = workbook.add_worksheet('授权码报表')
- sheetAuth.write(0, 0, "授权码数据记录表",formatHead)
- formatValueHead.set_align('center')
- sheetAuth.write(2, 0, '时间',formatValueHead)
- sheetAuth.write(2, 1, '用户',formatValueHead)
- sheetAuth.write(2, 2, '油站名称',formatValueHead)
- sheetAuth.write(2, 3, '油机机型',formatValueHead)
- sheetAuth.write(2, 4, '油机ID',formatValueHead)
- sheetAuth.write(2, 5, '功能码',formatValueHead)
- sheetAuth.write(2, 6, '授权码',formatValueHead)
- sheetAuth.write(2, 7, '授权码计数',formatValueHead)
- sheetAuth.write(2, 8, '油机类型',formatValueHead)
- sheetAuth.set_column('A:A', len('2019-00-00 00:00:00') + 1)
- sheetAuth.set_column('B:I', len('111111111111AAAB') + 1)
- sheetAuth.set_column('E:E',20 + 1)
- sheetAuth.set_column(13, 13, None, None, {'hidden': 1})
- for index,authvalue in enumerate(root):
- createTime = authvalue.find('createTime').text
- user = authvalue.find('user').text
- gasStation = authvalue.find('gasStation').text
- cpuID = authvalue.find('cpuID').text
- functionCode = authvalue.find('functionCode').text
- AuthCode = authvalue.find('AuthCode').text
- machineType = authvalue.find('machineType').text
- authCodeCount = authvalue.find('authCodeCount').text
- type = authvalue.find('type').text
- tmpformat = formatValue
-
- date_time = datetime.datetime.strptime(createTime, '%Y%m%d%H%M%S')
- sheetAuth.write(index + 3, 0, date_time.strftime('%Y-%m-%d %H:%M:%S'),tmpformat)
-
- sheetAuth.write(index + 3, 1, user, tmpformat)
- sheetAuth.write(index + 3, 2, gasStation, tmpformat)
- sheetAuth.write(index + 3, 3, machineType, tmpformat)
- sheetAuth.write(index + 3, 4, cpuID, tmpformat)
- sheetAuth.write(index + 3, 5, functionCode, tmpformat)
- sheetAuth.write(index + 3, 6, AuthCode, tmpformat)
- sheetAuth.write(index + 3, 7, authCodeCount, tmpformat)
- sheetAuth.write(index + 3, 8, type, tmpformat)
- workbook.close()
|