Merge branch 'feature/bs_excel' into feature/0611
Showing
1 changed file
with
16 additions
and
11 deletions
... | @@ -339,6 +339,11 @@ class BSWorkbook(Workbook): | ... | @@ -339,6 +339,11 @@ class BSWorkbook(Workbook): |
339 | ms = self.create_sheet('{0}{1}({2})'.format(self.meta_sheet_title, role_name, card)) | 339 | ms = self.create_sheet('{0}{1}({2})'.format(self.meta_sheet_title, role_name, card)) |
340 | for row in metadata_rows: | 340 | for row in metadata_rows: |
341 | ms.append(row) | 341 | ms.append(row) |
342 | if res_count_tuple[0] != res_count_tuple[1]: | ||
343 | for cell in ms[2]: | ||
344 | cell.fill = self.amount_fill | ||
345 | for cell in ms[3]: | ||
346 | cell.fill = self.amount_fill | ||
342 | return ms | 347 | return ms |
343 | 348 | ||
344 | @staticmethod | 349 | @staticmethod |
... | @@ -419,14 +424,20 @@ class BSWorkbook(Workbook): | ... | @@ -419,14 +424,20 @@ class BSWorkbook(Workbook): |
419 | for i in range(max_column - src_header_len): | 424 | for i in range(max_column - src_header_len): |
420 | header.append(None) | 425 | header.append(None) |
421 | 426 | ||
422 | add_col = ['核对结果', '合计'] | 427 | # 3.6 金额合计列 |
428 | add_col = ['核对结果'] | ||
423 | if amount_cell_idx is None: | 429 | if amount_cell_idx is None: |
424 | if income_cell_idx is not None or outlay_cell_idx is not None: | 430 | if income_cell_idx is not None or outlay_cell_idx is not None: |
425 | add_col = ['金额', '核对结果', '合计'] | 431 | add_col = ['金额', '核对结果'] |
426 | amount_cell_idx = len(header) | 432 | amount_cell_idx = len(header) |
433 | |||
434 | amount_col_letter = get_column_letter(amount_cell_idx + 1) if isinstance(amount_cell_idx, int) else None | ||
435 | amount_sum = '=SUBTOTAL(9,{0}:{0})'.format(amount_col_letter) if isinstance(amount_cell_idx, int) else '' | ||
436 | add_col.append('合计') | ||
437 | add_col.append(amount_sum) | ||
438 | |||
427 | header.extend(add_col) | 439 | header.extend(add_col) |
428 | result_idx = len(header) - 2 | 440 | result_idx = len(header) - 3 |
429 | amount_sum_idx = len(header) - 1 | ||
430 | 441 | ||
431 | tmp_ws = self.create_sheet('tmp_ws') | 442 | tmp_ws = self.create_sheet('tmp_ws') |
432 | tmp2_ws = self.create_sheet('tmp2_ws') | 443 | tmp2_ws = self.create_sheet('tmp2_ws') |
... | @@ -484,7 +495,7 @@ class BSWorkbook(Workbook): | ... | @@ -484,7 +495,7 @@ class BSWorkbook(Workbook): |
484 | row_num = 2 | 495 | row_num = 2 |
485 | for cell in rows: | 496 | for cell in rows: |
486 | row_num = cell.row | 497 | row_num = cell.row |
487 | if cell.value == role_name: | 498 | if isinstance(cell.value, str) and cell.value.find(role_name) != -1: |
488 | fill_row.add(summary_cell.row) | 499 | fill_row.add(summary_cell.row) |
489 | break | 500 | break |
490 | 501 | ||
... | @@ -534,7 +545,6 @@ class BSWorkbook(Workbook): | ... | @@ -534,7 +545,6 @@ class BSWorkbook(Workbook): |
534 | amount_cell.value, set()).add(amount_cell.row) | 545 | amount_cell.value, set()).add(amount_cell.row) |
535 | 546 | ||
536 | # 3.5.核对结果 | 547 | # 3.5.核对结果 |
537 | amount_col_letter = get_column_letter(amount_cell_idx + 1) | ||
538 | if amount_success and over_success and amount_cell.row > 2: | 548 | if amount_success and over_success and amount_cell.row > 2: |
539 | over_col_letter = get_column_letter(over_cell_idx + 1) | 549 | over_col_letter = get_column_letter(over_cell_idx + 1) |
540 | if is_reverse: | 550 | if is_reverse: |
... | @@ -544,11 +554,6 @@ class BSWorkbook(Workbook): | ... | @@ -544,11 +554,6 @@ class BSWorkbook(Workbook): |
544 | rows[result_idx].value = '=IF({2}{0}=ROUND(SUM({2}{1},{3}{0}),4), "{4}", "{5}")'.format( | 554 | rows[result_idx].value = '=IF({2}{0}=ROUND(SUM({2}{1},{3}{0}),4), "{4}", "{5}")'.format( |
545 | amount_cell.row, amount_cell.row - 1, over_col_letter, amount_col_letter, *self.proof_res) | 555 | amount_cell.row, amount_cell.row - 1, over_col_letter, amount_col_letter, *self.proof_res) |
546 | 556 | ||
547 | # 3.6 金额合计列 | ||
548 | amount_sum_letter = get_column_letter(amount_sum_idx + 1) | ||
549 | rows[amount_sum_idx].value = '=SUM({0}{1},{2}{3})'.format( | ||
550 | amount_sum_letter, row_num - 1, amount_col_letter, row_num) | ||
551 | |||
552 | # 3.2.提取信息、高亮 | 557 | # 3.2.提取信息、高亮 |
553 | # row = summary_cell.row | 558 | # row = summary_cell.row |
554 | if summary_cell is not None: | 559 | if summary_cell is not None: | ... | ... |
-
Please register or sign in to post a comment