回答編集履歴
4
書式の改善
test
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
```
|
2
|
+
|
1
3
|
from pathlib import Path
|
2
4
|
|
3
5
|
from openpyxl import load_workbook,Workbook
|
@@ -99,3 +101,5 @@
|
|
99
101
|
|
100
102
|
|
101
103
|
wb_new.save(('C:~~~~\②.部門格納場所\tmp_cc_summary.xlsx')
|
104
|
+
|
105
|
+
```
|
3
書式の改善
test
CHANGED
@@ -62,9 +62,7 @@
|
|
62
62
|
|
63
63
|
return([[cell.value for cell in row] for row in t_2d])
|
64
64
|
|
65
|
-
l_2d = get_value_list(ws['U6:AF163'])
|
65
|
+
l_2d = get_value_list(ws['U6:AF163'])# 対象シート内セルの値取得_CC番号を取得して後ほどSetする側の特定に紐づける
|
66
|
-
|
67
|
-
# 対象シート内セルの値取得_CC番号を取得して後ほどSetする側の特定に紐づける
|
68
66
|
|
69
67
|
cell_cc_chk = ws.cell(column=2, row=2).value
|
70
68
|
|
2
書式の改善
test
CHANGED
@@ -1,8 +1,54 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
|
3
|
+
from openpyxl import load_workbook,Workbook
|
4
|
+
|
5
|
+
import os
|
6
|
+
|
7
|
+
import openpyxl as px
|
8
|
+
|
9
|
+
import pprint
|
10
|
+
|
11
|
+
|
12
|
+
|
1
|
-
Path_is = Path('C:~~~~\①.CC格納場所')
|
13
|
+
Path_is = Path(('C:~~~~\①.CC格納場所'))
|
14
|
+
|
15
|
+
print('Path_is_a=',Path_is)
|
2
16
|
|
3
17
|
|
4
18
|
|
5
19
|
for i , file in enumerate(Path_is.glob('*.xlsx')):
|
20
|
+
|
21
|
+
fill = px.styles.PatternFill(patternType='solid',fgColor ='D1FE7B',bgColor='D1FE7B')#セル書式変更
|
22
|
+
|
23
|
+
wb_new = Workbook()
|
24
|
+
|
25
|
+
ws_new = wb_new.active
|
26
|
+
|
27
|
+
ws_new.title = 'tmp_cc_summary'
|
28
|
+
|
29
|
+
ws_new['B1'].fill = fill ; ws_new['B1']= '4月'
|
30
|
+
|
31
|
+
ws_new['C1'].fill = fill ; ws_new['C1'] = '5月'
|
32
|
+
|
33
|
+
ws_new['D1'].fill = fill ; ws_new['D1'] = '6月'
|
34
|
+
|
35
|
+
ws_new['E1'].fill = fill ; ws_new['E1'] = '7月'
|
36
|
+
|
37
|
+
ws_new['F1'].fill = fill ; ws_new['F1'] = '8月'
|
38
|
+
|
39
|
+
ws_new['G1'].fill = fill ; ws_new['G1'] = '9月'
|
40
|
+
|
41
|
+
ws_new['H1'].fill = fill ; ws_new['H1'] = '10月'
|
42
|
+
|
43
|
+
ws_new['I1'].fill = fill ; ws_new['I1'] = '11月'
|
44
|
+
|
45
|
+
ws_new['J1'].fill = fill ; ws_new['J1'] = '12月'
|
46
|
+
|
47
|
+
ws_new['K1'].fill = fill ; ws_new['K1'] = '1月'
|
48
|
+
|
49
|
+
ws_new['L1'].fill = fill ; ws_new['L1'] = '2月'
|
50
|
+
|
51
|
+
ws_new['M1'].fill = fill ; ws_new['M1'] = '3月'
|
6
52
|
|
7
53
|
wb = load_workbook(file, data_only=True)
|
8
54
|
|
@@ -18,13 +64,15 @@
|
|
18
64
|
|
19
65
|
l_2d = get_value_list(ws['U6:AF163'])
|
20
66
|
|
67
|
+
# 対象シート内セルの値取得_CC番号を取得して後ほどSetする側の特定に紐づける
|
68
|
+
|
21
69
|
cell_cc_chk = ws.cell(column=2, row=2).value
|
22
70
|
|
23
71
|
|
24
72
|
|
25
|
-
for ws in
|
73
|
+
for ws in enumerate(Path_is.glob('*.xlsx')):
|
26
74
|
|
27
|
-
ws_new.title = str(cell_cc_chk)
|
75
|
+
ws_new.title = str(cell_cc_chk) #get_value_listよりCCを指すB2セル値をシートにセットする
|
28
76
|
|
29
77
|
def write_list_2d(ws_new, l_2d, start_row,start_col):
|
30
78
|
|
@@ -38,10 +86,18 @@
|
|
38
86
|
|
39
87
|
value=l_2d[y][x])
|
40
88
|
|
41
|
-
write_list_2d(ws_new, l_2d, 2, 2) #row=2, col=2を始点に書き込み
|
89
|
+
write_list_2d(ws_new, l_2d, 2, 2) #row=2, col=2を始点に書き込み
|
42
90
|
|
91
|
+
ws_cc = wb_new.copy_worksheet(ws_new)
|
92
|
+
|
43
|
-
w
|
93
|
+
ws_cc.title = 'copy_test'
|
44
94
|
|
45
95
|
print ("★cell_cc_chk = ",cell_cc_chk)
|
46
96
|
|
47
97
|
print('★l_2d = ', l_2d)
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
wb_new.save(('C:~~~~\②.部門格納場所\tmp_cc_summary.xlsx')
|
1
誤字の修正
test
CHANGED
@@ -18,15 +18,13 @@
|
|
18
18
|
|
19
19
|
l_2d = get_value_list(ws['U6:AF163'])
|
20
20
|
|
21
|
-
# 対象シート内セルの値取得_CC番号を取得して後ほどSetする側の特定に紐づける
|
22
|
-
|
23
21
|
cell_cc_chk = ws.cell(column=2, row=2).value
|
24
22
|
|
25
23
|
|
26
24
|
|
27
25
|
for ws in wb:
|
28
26
|
|
29
|
-
ws_new.title = str(cell_cc_chk)
|
27
|
+
ws_new.title = str(cell_cc_chk)
|
30
28
|
|
31
29
|
def write_list_2d(ws_new, l_2d, start_row,start_col):
|
32
30
|
|