TankHandler.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. #coding=utf-8
  2. import os
  3. import xml.etree.ElementTree as ET
  4. import xlwt
  5. #from xlwt import Workbook, XFStyle, Borders, Pattern, Font
  6. import datetime
  7. import time
  8. import xlsxwriter
  9. import sys
  10. sys.path.append("C:\Python\Python36\Lib")
  11. import configparser
  12. start = time.time()
  13. def getHeaderStyle():
  14. return xlwt.easyxf('font:height 720;') # 36pt,类型小初的字号
  15. def getHeaderStyleFont():
  16. fnt = Font()
  17. fnt.height = 400
  18. fnt.bold = True
  19. style = XFStyle()
  20. style.font = fnt
  21. return style
  22. def gettitlestyle():
  23. fnt = Font()
  24. fnt.bold = True
  25. alignment = xlwt.Alignment() # Create Alignment
  26. alignment.horz = xlwt.Alignment.HORZ_CENTER # May be: HORZ_GENERAL, HORZ_LEFT, HORZ_CENTER, HORZ_RIGHT, HORZ_FILLED, HORZ_JUSTIFIED, HORZ_CENTER_ACROSS_SEL, HORZ_DISTRIBUTED
  27. alignment.vert = xlwt.Alignment.VERT_CENTER # May be: VERT_TOP, VERT_CENTER, VERT_BOTTOM, VERT_JUSTIFIED, VERT_DISTRIBUTED
  28. style = XFStyle()
  29. style.alignment = alignment # Add Alignment to Style
  30. style.font = fnt
  31. return style
  32. def getcontentstyle():
  33. fnt = Font()
  34. alignment = xlwt.Alignment() # Create Alignment
  35. alignment.horz = xlwt.Alignment.HORZ_CENTER # May be: HORZ_GENERAL, HORZ_LEFT, HORZ_CENTER, HORZ_RIGHT, HORZ_FILLED, HORZ_JUSTIFIED, HORZ_CENTER_ACROSS_SEL, HORZ_DISTRIBUTED
  36. alignment.vert = xlwt.Alignment.VERT_CENTER # May be: VERT_TOP, VERT_CENTER, VERT_BOTTOM, VERT_JUSTIFIED, VERT_DISTRIBUTED
  37. style = XFStyle()
  38. style.alignment = alignment # Add Alignment to Style
  39. style.font = fnt
  40. return style
  41. workbook = xlsxwriter.Workbook('demo.xlsx')
  42. tree = ET.parse('C:\\Tokheim\\xml\\TankReport.xml')
  43. root = tree.getroot()
  44. tag = root.tag
  45. #workbook = xlsxwriter.Workbook('c:\\tokheim\\'+'环境数据报表'+root.get('attrtime')+'.xlsx')
  46. fn = 'C:\\Tokheim\\环境数据报表' + root.get('attrtime') + '.xlsx'
  47. sectionname = 'TankReport'
  48. cfgpath = "C:\\Tokheim\\plugs\\" + sectionname + "cfg.ini"
  49. workbook = xlsxwriter.Workbook(fn)
  50. try:
  51. workbook.close()
  52. except:
  53. state = "2"
  54. conf = configparser.ConfigParser()
  55. conf.add_section(sectionname)
  56. conf.set(sectionname, "State", state)
  57. conf.write(open(cfgpath, "w"))
  58. exit(1)
  59. workbook = xlsxwriter.Workbook(fn)
  60. recordcount = 0
  61. for index,oilgun in enumerate(root):
  62. sheetoil = workbook.add_worksheet('环境数据报表')
  63. sheetgrid = workbook.add_worksheet('环境数据图表')
  64. sheetoil.write(0,0,"油气回收在线监测环境数据表")
  65. sheetoil.write(4, 0, '计数')
  66. sheetoil.write(4, 1, '时间')
  67. sheetoil.write(4, 2, '油罐压力1')
  68. sheetoil.write(4, 3, '油罐压力2')
  69. sheetoil.write(4, 4, '油罐压力3')
  70. sheetoil.write(4, 5, '油罐压力4')
  71. sheetoil.write(4, 6, '油罐温度1')
  72. sheetoil.write(4, 7, '油罐温度2')
  73. sheetoil.write(4, 8, '油罐温度3')
  74. sheetoil.write(4, 9, '油罐温度4')
  75. sheetoil.write(4, 10, '管线压力')
  76. sheetoil.write(4, 11, '卸油区浓度')
  77. sheetoil.write(4, 12, '三次回收浓度')
  78. sheetoil.write(4, 13, '人孔井1浓度')
  79. sheetoil.write(4, 14, '人孔井2浓度')
  80. sheetoil.write(4, 15, '人孔井3浓度')
  81. sheetoil.write(4, 16, '人孔井4浓度')
  82. sheetoil.write(4, 17, '加油区1浓度')
  83. sheetoil.write(4, 18, '加油区2浓度')
  84. sheetoil.write(4, 19, '加油区3浓度')
  85. sheetoil.write(4, 20, '加油区4浓度')
  86. sheetoil.write(4, 21, '加油区5浓度')
  87. sheetoil.write(4, 22, '加油区6浓度')
  88. sheetoil.write(4, 23, '加油区7浓度')
  89. sheetoil.write(4, 24, '加油区8浓度')
  90. sheetoil.write(4, 25, '加油区9浓度')
  91. sheetoil.write(4, 26, '加油区10浓度')
  92. sheetoil.write(4, 27, '加油区11浓度')
  93. sheetoil.write(4, 28, '加油区12浓度')
  94. sheetoil.write(4, 50, '油罐温度*10')
  95. sheetoil.write(4, 51, '油气浓度*10')
  96. sheetoil.set_column('B:B', 20)
  97. sheetoil.set_column('C:BA', 13)
  98. count=0
  99. for guncol in oilgun:
  100. alcounts = 0
  101. avicounts = 0
  102. count=0
  103. for index,gunele in enumerate(guncol):
  104. recordcount = recordcount + 1
  105. timetxt = gunele.find('time').text
  106. sheetoil.write(index + 5, 0, int(gunele.find('count').text))
  107. date_time = datetime.datetime.strptime(timetxt, '%Y%m%d%H%M%S')
  108. sheetoil.write(index+5, 1, date_time.strftime('%Y-%m-%d %H:%M:%S'))
  109. sheetoil.write(index+5, 2, float(gunele.find('pressure1').text))
  110. sheetoil.write(index+5, 3, float(gunele.find('pressure2').text))
  111. sheetoil.write(index+5, 4, float(gunele.find('pressure3').text))
  112. sheetoil.write(index+5, 5, float(gunele.find('pressure4').text))
  113. sheetoil.write(index+5, 6, float(gunele.find('temp1').text))
  114. sheetoil.write(index+5, 7, float(gunele.find('temp2').text))
  115. sheetoil.write(index+5, 8, float(gunele.find('temp3').text))
  116. sheetoil.write(index+5, 9, float(gunele.find('temp4').text))
  117. sheetoil.write(index+5, 10, float(gunele.find('liquid').text))
  118. sheetoil.write(index+5, 11, float(gunele.find('gaspercentage').text))
  119. sheetoil.write(index+5, 12, float(gunele.find('postpercentage').text))
  120. sheetoil.write(index+5, 13, float(gunele.find('wellpercentage1').text))
  121. sheetoil.write(index+5, 14, float(gunele.find('wellpercentage2').text))
  122. sheetoil.write(index+5, 15, float(gunele.find('wellpercentage3').text))
  123. sheetoil.write(index+5, 16, float(gunele.find('wellpercentage4').text))
  124. sheetoil.write(index+5, 17, float(gunele.find('oilpercentage1').text))
  125. sheetoil.write(index+5, 18, float(gunele.find('oilpercentage2').text))
  126. sheetoil.write(index+5, 19, float(gunele.find('oilpercentage3').text))
  127. sheetoil.write(index+5, 20, float(gunele.find('oilpercentage4').text))
  128. sheetoil.write(index+5, 21, float(gunele.find('oilpercentage5').text))
  129. sheetoil.write(index+5, 22, float(gunele.find('oilpercentage6').text))
  130. sheetoil.write(index+5, 23, float(gunele.find('oilpercentage7').text))
  131. sheetoil.write(index+5, 24, float(gunele.find('oilpercentage8').text))
  132. sheetoil.write(index+5, 25, float(gunele.find('oilpercentage9').text))
  133. sheetoil.write(index+5, 26, float(gunele.find('oilpercentage10').text))
  134. sheetoil.write(index+5, 27, float(gunele.find('oilpercentage11').text))
  135. sheetoil.write(index+5, 28, float(gunele.find('oilpercentage12').text))
  136. sheetoil.write_number(index+5, 50, float(gunele.find('temp1').text) * 10)
  137. sheetoil.write(index + 5, 51, float(gunele.find('gaspercentage').text) * 10)
  138. count = count + 1
  139. chart1 = workbook.add_chart({'type': 'scatter'})
  140. #chart1.set_size({'width': 650, 'height': 480})
  141. # Configure second series. Note use of alternative syntax to define ranges.
  142. chart1.add_series({
  143. 'name': ['环境数据报表', 4, 2],
  144. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  145. 'values': ['环境数据报表', 5, 2, count + 5 - 1, 2],
  146. 'line': {'color': '#005500',
  147. 'width': 1},
  148. 'marker': {
  149. 'type': 'none',
  150. 'size': 5,
  151. },
  152. })
  153. chart1.add_series({
  154. 'name': ['环境数据报表', 4, 3],
  155. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  156. 'values': ['环境数据报表', 5, 3, count + 5 - 1, 3],
  157. 'line': {'color': '#0000ff',
  158. 'width': 1},
  159. 'marker': {
  160. 'type': 'none',
  161. 'size': 5,
  162. },
  163. })
  164. chart1.add_series({
  165. 'name': ['环境数据报表', 4, 4],
  166. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  167. 'values': ['环境数据报表', 5, 4, count + 5 - 1, 4],
  168. 'line': {'color': '#00ff00',
  169. 'width': 1},
  170. 'marker': {
  171. 'type': 'none',
  172. 'size': 5,
  173. },
  174. })
  175. chart1.add_series({
  176. 'name': ['环境数据报表', 4, 5],
  177. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  178. 'values': ['环境数据报表', 5, 5, count + 5 - 1, 5],
  179. 'line': {'color': '#ff0000',
  180. 'width': 1},
  181. 'marker': {
  182. 'type': 'none',
  183. 'size': 5,
  184. },
  185. })
  186. # Add a chart title and some axis labels.
  187. chart1.set_title ({'name': '油罐压力'})
  188. chart1.set_x_axis({'name': '计数'})
  189. chart1.set_y_axis({'name': '压力值'})
  190. # Set an Excel chart style.
  191. chart1.set_style(11)
  192. # Insert the chart into the worksheet (with an offset).
  193. sheetgrid.insert_chart('A1', chart1, {'x_offset': 5, 'y_offset': 5})
  194. chart2 = workbook.add_chart({'type': 'scatter'})
  195. chart2.add_series({
  196. 'name': ['环境数据报表', 4, 6],
  197. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  198. 'values': ['环境数据报表', 5, 6, count + 5 - 1, 6],
  199. 'line': {'color': '#aa5555',
  200. 'width': 1},
  201. 'marker': {
  202. 'type': 'none',
  203. 'size': 5,
  204. },
  205. })
  206. chart2.add_series({
  207. 'name': ['环境数据报表', 4, 7],
  208. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  209. 'values': ['环境数据报表', 5, 7, count + 5 - 1, 7],
  210. 'line': {'color': '#00ff00',
  211. 'width': 1},
  212. 'marker': {
  213. 'type': 'none',
  214. 'size': 5,
  215. },
  216. })
  217. chart2.add_series({
  218. 'name': ['环境数据报表', 4, 8],
  219. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  220. 'values': ['环境数据报表', 5, 8, count + 5 - 1, 8],
  221. 'line': {'color': '#ffff00',
  222. 'width': 1},
  223. 'marker': {
  224. 'type': 'none',
  225. 'size': 5,
  226. },
  227. })
  228. chart2.add_series({
  229. 'name': ['环境数据报表', 4, 9],
  230. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  231. 'values': ['环境数据报表', 5, 9, count + 5 - 1, 9],
  232. 'line': {'color': '#ff0000',
  233. 'width': 1},
  234. 'marker': {
  235. 'type': 'none',
  236. 'size': 5,
  237. },
  238. })
  239. chart2.set_title({'name': '油罐温度'})
  240. chart2.set_x_axis({'name': '计数'})
  241. chart2.set_y_axis({'name': '温度'})
  242. chart2.set_style(11)
  243. sheetgrid.insert_chart('I1', chart2, {'x_offset': 5, 'y_offset': 5})
  244. chart3 = workbook.add_chart({'type': 'scatter'})
  245. chart3.add_series({
  246. 'name': ['环境数据报表', 4, 10],
  247. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  248. 'values': ['环境数据报表', 5, 10, count + 5 - 1, 10],
  249. 'line': {'color': 'green',
  250. 'width': 1},
  251. 'marker': {
  252. 'type': 'none',
  253. 'size': 5,
  254. },
  255. })
  256. chart3.set_title({'name': '管线压力'})
  257. chart3.set_x_axis({'name': '计数'})
  258. chart3.set_y_axis({'name': '管线压力'})
  259. chart3.set_style(11)
  260. sheetgrid.insert_chart('A16', chart3, {'x_offset': 5, 'y_offset': 11})
  261. chart4 = workbook.add_chart({'type': 'scatter'})
  262. chart4.add_series({
  263. 'name': ['环境数据报表', 4, 11],
  264. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  265. 'values': ['环境数据报表', 5, 11, count + 5 - 1, 11],
  266. 'line': {'color': 'yellow',
  267. 'width': 1},
  268. 'marker': {
  269. 'type': 'none',
  270. 'size': 5,
  271. },
  272. })
  273. chart4.set_title({'name': '卸油区浓度'})
  274. chart4.set_x_axis({'name': '计数'})
  275. chart4.set_y_axis({'name': '浓度'})
  276. chart4.set_style(11)
  277. sheetgrid.insert_chart('I16', chart4, {'x_offset': 5, 'y_offset': 5})
  278. chart5 = workbook.add_chart({'type': 'scatter'})
  279. chart5.add_series({
  280. 'name': ['环境数据报表', 4, 12],
  281. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  282. 'values': ['环境数据报表', 5, 12, count + 5 - 1, 12],
  283. 'line': {'color': 'green',
  284. 'width': 1},
  285. 'marker': {
  286. 'type': 'none',
  287. 'size': 5,
  288. },
  289. })
  290. chart5.set_title({'name': '三次回收浓度'})
  291. chart5.set_x_axis({'name': '计数'})
  292. chart5.set_y_axis({'name': '浓度'})
  293. chart5.set_style(11)
  294. sheetgrid.insert_chart('A31', chart5, {'x_offset': 5, 'y_offset': 11})
  295. chart6 = workbook.add_chart({'type': 'scatter'})
  296. chart6.add_series({
  297. 'name': ['环境数据报表', 4, 13],
  298. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  299. 'values': ['环境数据报表', 5, 13, count + 5 - 1, 13],
  300. 'line': {'color': 'green',
  301. 'width': 1},
  302. 'marker': {
  303. 'type': 'none',
  304. 'size': 5,
  305. },
  306. })
  307. chart6.add_series({
  308. 'name': ['环境数据报表', 4, 14],
  309. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  310. 'values': ['环境数据报表', 5, 14, count + 5 - 1, 14],
  311. 'line': {'color': '#00ff00',
  312. 'width': 1},
  313. 'marker': {
  314. 'type': 'none',
  315. 'size': 5,
  316. },
  317. })
  318. chart6.add_series({
  319. 'name': ['环境数据报表', 4, 15],
  320. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  321. 'values': ['环境数据报表', 5, 15, count + 5 - 1, 15],
  322. 'line': {'color': '#ffff00',
  323. 'width': 1},
  324. 'marker': {
  325. 'type': 'none',
  326. 'size': 5,
  327. },
  328. })
  329. chart6.add_series({
  330. 'name': ['环境数据报表', 4, 16],
  331. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  332. 'values': ['环境数据报表', 5, 16, count + 5 - 1, 16],
  333. 'line': {'color': '#ff0000',
  334. 'width': 1},
  335. 'marker': {
  336. 'type': 'none',
  337. 'size': 5,
  338. },
  339. })
  340. chart6.set_title({'name': '人孔井浓度'})
  341. chart6.set_x_axis({'name': '计数'})
  342. chart6.set_y_axis({'name': '浓度'})
  343. chart6.set_style(11)
  344. sheetgrid.insert_chart('I31', chart6, {'x_offset': 5, 'y_offset': 11})
  345. chart7 = workbook.add_chart({'type': 'scatter'})
  346. chart7.set_size({'width': 650, 'height': 480})
  347. chart7.add_series({
  348. 'name': ['环境数据报表', 4, 17],
  349. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  350. 'values': ['环境数据报表', 5, 17, count + 5 - 1, 17],
  351. 'line': {'color': 'green',
  352. 'width': 1},
  353. 'marker': {
  354. 'type': 'none',
  355. 'size': 5,
  356. },
  357. })
  358. chart7.add_series({
  359. 'name': ['环境数据报表', 4, 18],
  360. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  361. 'values': ['环境数据报表', 5, 18, count + 5 - 1, 18],
  362. 'line': {'color': '#000000',
  363. 'width': 1},
  364. 'marker': {
  365. 'type': 'none',
  366. 'size': 5,
  367. },
  368. })
  369. chart7.add_series({
  370. 'name': ['环境数据报表', 4, 19],
  371. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  372. 'values': ['环境数据报表', 5, 19, count + 5 - 1, 19],
  373. 'line': {'color': '#aaaaff',
  374. 'width': 1},
  375. 'marker': {
  376. 'type': 'none',
  377. 'size': 5,
  378. },
  379. })
  380. chart7.add_series({
  381. 'name': ['环境数据报表', 4, 20],
  382. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  383. 'values': ['环境数据报表', 5, 20, count + 5 - 1, 20],
  384. 'line': {'color': '#8888ff',
  385. 'width': 1},
  386. 'marker': {
  387. 'type': 'none',
  388. 'size': 5,
  389. },
  390. })
  391. chart7.add_series({
  392. 'name': ['环境数据报表', 4, 21],
  393. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  394. 'values': ['环境数据报表', 5, 21, count + 5 - 1, 21],
  395. 'line': {'color': '#ffaaaa',
  396. 'width': 1},
  397. 'marker': {
  398. 'type': 'none',
  399. 'size': 5,
  400. },
  401. })
  402. chart7.add_series({
  403. 'name': ['环境数据报表', 4, 22],
  404. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  405. 'values': ['环境数据报表', 5, 22, count + 5 - 1, 22],
  406. 'line': {'color': '#ffaa11',
  407. 'width': 1},
  408. 'marker': {
  409. 'type': 'none',
  410. 'size': 5,
  411. },
  412. })
  413. chart7.add_series({
  414. 'name': ['环境数据报表', 4, 23],
  415. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  416. 'values': ['环境数据报表', 5, 23, count + 5 - 1, 23],
  417. 'line': {'color': '#ff11aa',
  418. 'width': 1},
  419. 'marker': {
  420. 'type': 'none',
  421. 'size': 5,
  422. },
  423. })
  424. chart7.add_series({
  425. 'name': ['环境数据报表', 4, 24],
  426. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  427. 'values': ['环境数据报表', 5, 24, count + 5 - 1, 24],
  428. 'line': {'color': '#ff8888',
  429. 'width': 1},
  430. 'marker': {
  431. 'type': 'none',
  432. 'size': 5,
  433. },
  434. })
  435. chart7.add_series({
  436. 'name': ['环境数据报表', 4, 25],
  437. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  438. 'values': ['环境数据报表', 5, 25, count + 5 - 1, 25],
  439. 'line': {'color': '#33ffaa',
  440. 'width': 1},
  441. 'marker': {
  442. 'type': 'none',
  443. 'size': 5,
  444. },
  445. })
  446. chart7.add_series({
  447. 'name': ['环境数据报表', 4, 26],
  448. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  449. 'values': ['环境数据报表', 5, 26, count + 5 - 1, 26],
  450. 'line': {'color': '#553311',
  451. 'width': 1},
  452. 'marker': {
  453. 'type': 'none',
  454. 'size': 5,
  455. },
  456. })
  457. chart7.add_series({
  458. 'name': ['环境数据报表', 4, 27],
  459. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  460. 'values': ['环境数据报表', 5, 27, count + 5 - 1, 27],
  461. 'line': {'color': '#5577aa',
  462. 'width': 1},
  463. 'marker': {
  464. 'type': 'none',
  465. 'size': 5,
  466. },
  467. })
  468. chart7.add_series({
  469. 'name': ['环境数据报表', 4, 28],
  470. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  471. 'values': ['环境数据报表', 5, 28, count + 5 - 1, 28],
  472. 'line': {'color': '#44ff44',
  473. 'width': 1},
  474. 'marker': {
  475. 'type': 'none',
  476. 'size': 5,
  477. },
  478. })
  479. chart7.set_title({'name': '加油区浓度'})
  480. chart7.set_x_axis({'name': '计数'})
  481. chart7.set_y_axis({'name': '浓度'})
  482. chart7.set_style(11)
  483. sheetgrid.insert_chart('A46', chart7, {'x_offset': 5, 'y_offset': 11})
  484. '''
  485. chart5 = workbook.add_chart({'type': 'scatter'})
  486. chart5.set_size({'width': 650, 'height': 480})
  487. chart5.add_series({
  488. 'name': ['环境数据报表', 4, 2],
  489. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  490. 'values': ['环境数据报表', 5, 2, count + 5 - 1, 2],
  491. 'line': {'color': 'blue',
  492. 'width': 1},
  493. 'marker': {
  494. 'type': 'none',
  495. 'size': 5,
  496. },
  497. })
  498. chart5.add_series({
  499. 'name': ['环境数据报表', 4, 50],
  500. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  501. 'values': ['环境数据报表', 5, 50, count + 5 - 1, 50],
  502. 'line': {'color': 'red',
  503. 'width': 1},
  504. 'marker': {
  505. 'type': 'none',
  506. 'size': 5,
  507. },
  508. })
  509. chart5.add_series({
  510. 'name': ['环境数据报表', 4, 4],
  511. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  512. 'values': ['环境数据报表', 5, 4, count + 5 - 1, 4],
  513. 'line': {'color': 'green',
  514. 'width': 1},
  515. 'marker': {
  516. 'type': 'none',
  517. 'size': 5,
  518. },
  519. })
  520. chart5.add_series({
  521. 'name': ['环境数据报表', 4, 51],
  522. 'categories': ['环境数据报表', 5, 0, count + 5 - 1, 0],
  523. 'values': ['环境数据报表', 5, 51, count + 5 - 1, 51],
  524. 'line': {'color': 'yellow',
  525. 'width': 1},
  526. 'marker': {
  527. 'type': 'none',
  528. 'size': 5,
  529. },
  530. })
  531. chart5.set_title({'name': '环境数据'})
  532. chart5.set_x_axis({'name': '计数'})
  533. chart5.set_y_axis({'name': '数据'})
  534. chart5.set_style(11)
  535. sheetgrid.insert_chart('A31', chart5, {'x_offset': 5, 'y_offset': 5})
  536. '''
  537. state = "0"
  538. try:
  539. workbook.close()
  540. state = "1"
  541. except:
  542. state = "2"
  543. end = time.time()
  544. stime = end -start
  545. print(stime)
  546. print(recordcount)
  547. print(state)
  548. conf = configparser.ConfigParser()
  549. conf.add_section(sectionname)
  550. conf.set(sectionname, "State", state)
  551. conf.set(sectionname, "time", str(stime))
  552. conf.set(sectionname, "count", str(recordcount))
  553. conf.write(open(cfgpath, "w"))