| @@ 455-503 (lines=49) @@ | ||
| 452 | max_row = 38 + len(time) |
|
| 453 | print("max_row", max_row) |
|
| 454 | ||
| 455 | if has_data: |
|
| 456 | for i in range(0, len(time)): |
|
| 457 | col = 'B' |
|
| 458 | row = str(39 + i) |
|
| 459 | # col = chr(ord('B') + i) |
|
| 460 | ws[col + row].font = title_font |
|
| 461 | ws[col + row].alignment = c_c_alignment |
|
| 462 | ws[col + row] = time[i] |
|
| 463 | ws[col + row].border = f_border |
|
| 464 | ||
| 465 | for i in range(0, ca_len): |
|
| 466 | # 38 title |
|
| 467 | col = chr(ord('C') + i) |
|
| 468 | ||
| 469 | ws[col + '38'].fill = table_fill |
|
| 470 | ws[col + '38'].font = title_font |
|
| 471 | ws[col + '38'].alignment = c_c_alignment |
|
| 472 | ws[col + '38'] = report['names'][i] + " (" + report['units'][i] + ")" |
|
| 473 | ws[col + '38'].border = f_border |
|
| 474 | ||
| 475 | # 39 data |
|
| 476 | time = times[i] |
|
| 477 | time_len = len(time) |
|
| 478 | ||
| 479 | for j in range(0, time_len): |
|
| 480 | row = str(39 + j) |
|
| 481 | # col = chr(ord('B') + i) |
|
| 482 | ws[col + row].font = title_font |
|
| 483 | ws[col + row].alignment = c_c_alignment |
|
| 484 | ws[col + row] = round(report['values'][i][j], 0) |
|
| 485 | ws[col + row].border = f_border |
|
| 486 | # bar |
|
| 487 | # 39~: bar |
|
| 488 | bar = BarChart() |
|
| 489 | labels = Reference(ws, min_col=2, min_row=39, max_row=max_row + 1) |
|
| 490 | bar_data = Reference(ws, min_col=3 + i, min_row=38, max_row=max_row + 1) # openpyxl bug |
|
| 491 | bar.add_data(bar_data, titles_from_data=True) |
|
| 492 | bar.set_categories(labels) |
|
| 493 | bar.height = 5.25 # cm 1.05*5 1.05cm = 30 pt |
|
| 494 | bar.width = 18 |
|
| 495 | # pie.title = "Pies sold by category" |
|
| 496 | bar.dLbls = DataLabelList() |
|
| 497 | bar.dLbls.showCatName = True # label show |
|
| 498 | bar.dLbls.showVal = True # val show |
|
| 499 | bar.dLbls.showPercent = True # percent show |
|
| 500 | # s1 = CharacterProperties(sz=1800) # font size *100 |
|
| 501 | chart_col = chr(ord('B') + 2 * i) |
|
| 502 | chart_cell = chart_col + str(max_row + 2) |
|
| 503 | ws.add_chart(bar, chart_cell) |
|
| 504 | else: |
|
| 505 | for i in range(37, 69 + 1): |
|
| 506 | ws.row_dimensions[i].height = 0.1 |
|
| @@ 284-332 (lines=49) @@ | ||
| 281 | has_data = True |
|
| 282 | max_row = 12 + len(time) |
|
| 283 | ||
| 284 | if has_data: |
|
| 285 | for i in range(0, len(time)): |
|
| 286 | col = 'B' |
|
| 287 | row = str(13 + i) |
|
| 288 | # col = chr(ord('B') + i) |
|
| 289 | ws[col + row].font = title_font |
|
| 290 | ws[col + row].alignment = c_c_alignment |
|
| 291 | ws[col + row] = time[i] |
|
| 292 | ws[col + row].border = f_border |
|
| 293 | ||
| 294 | for i in range(0, ca_len): |
|
| 295 | # 12 title |
|
| 296 | col = chr(ord('C') + i) |
|
| 297 | ||
| 298 | ws[col + '12'].fill = table_fill |
|
| 299 | ws[col + '12'].font = title_font |
|
| 300 | ws[col + '12'].alignment = c_c_alignment |
|
| 301 | ws[col + '12'] = data['meter']['energy_category_name'] + " (" + data['meter']['unit_of_measure'] + ")" |
|
| 302 | ws[col + '12'].border = f_border |
|
| 303 | ||
| 304 | # 13 data |
|
| 305 | time = times |
|
| 306 | time_len = len(time) |
|
| 307 | ||
| 308 | for j in range(0, time_len): |
|
| 309 | row = str(13 + j) |
|
| 310 | # col = chr(ord('B') + i) |
|
| 311 | ws[col + row].font = title_font |
|
| 312 | ws[col + row].alignment = c_c_alignment |
|
| 313 | ws[col + row] = round(report['values'][j], 0) |
|
| 314 | ws[col + row].border = f_border |
|
| 315 | # bar |
|
| 316 | # 13~: bar |
|
| 317 | bar = BarChart() |
|
| 318 | labels = Reference(ws, min_col=2, min_row=13, max_row=max_row + 1) |
|
| 319 | bar_data = Reference(ws, min_col=3 + i, min_row=12, max_row=max_row + 1) # openpyxl bug |
|
| 320 | bar.add_data(bar_data, titles_from_data=True) |
|
| 321 | bar.set_categories(labels) |
|
| 322 | bar.height = 5.25 # cm 1.05*5 1.05cm = 30 pt |
|
| 323 | bar.width = 18 |
|
| 324 | # pie.title = "Pies sold by category" |
|
| 325 | bar.dLbls = DataLabelList() |
|
| 326 | bar.dLbls.showCatName = True # 标签显示 |
|
| 327 | bar.dLbls.showVal = True # 数量显示 |
|
| 328 | bar.dLbls.showPercent = True # 百分比显示 |
|
| 329 | # s1 = CharacterProperties(sz=1800) # 图表中字体大小 *100 |
|
| 330 | chart_col = chr(ord('B') + 2 * i) |
|
| 331 | chart_cell = chart_col + str(max_row + 2) |
|
| 332 | ws.add_chart(bar, chart_cell) |
|
| 333 | else: |
|
| 334 | for i in range(11, 43 + 1): |
|
| 335 | ws.row_dimensions[i].height = 0.0 |
|