@@ 54-187 (lines=134) @@ | ||
51 | return base64_message |
|
52 | ||
53 | ||
54 | def generate_excel(report, space_name, reporting_start_datetime_local, reporting_end_datetime_local, language): |
|
55 | ||
56 | trans = get_translation(language) |
|
57 | trans.install() |
|
58 | _ = trans.gettext |
|
59 | ||
60 | wb = Workbook() |
|
61 | ws = wb.active |
|
62 | ws.title = "ShopFloorBatch" |
|
63 | ||
64 | # Row height |
|
65 | ws.row_dimensions[1].height = 102 |
|
66 | for i in range(2, 5 + 1): |
|
67 | ws.row_dimensions[i].height = 42 |
|
68 | ||
69 | for i in range(6, len(report['shopfloors']) + 15): |
|
70 | ws.row_dimensions[i].height = 60 |
|
71 | ||
72 | # Col width |
|
73 | ws.column_dimensions['A'].width = 1.5 |
|
74 | ||
75 | ws.column_dimensions['B'].width = 25.0 |
|
76 | ||
77 | for i in range(ord('C'), ord('L')): |
|
78 | ws.column_dimensions[chr(i)].width = 15.0 |
|
79 | ||
80 | # Font |
|
81 | name_font = Font(name='Arial', size=15, bold=True) |
|
82 | title_font = Font(name='Arial', size=15, bold=True) |
|
83 | data_font = Font(name='Franklin Gothic Book', size=11) |
|
84 | ||
85 | table_fill = PatternFill(fill_type='solid', fgColor='90ee90') |
|
86 | f_border = Border(left=Side(border_style='medium'), |
|
87 | right=Side(border_style='medium'), |
|
88 | bottom=Side(border_style='medium'), |
|
89 | top=Side(border_style='medium') |
|
90 | ) |
|
91 | b_border = Border( |
|
92 | bottom=Side(border_style='medium'), |
|
93 | ) |
|
94 | ||
95 | b_c_alignment = Alignment(vertical='bottom', |
|
96 | horizontal='center', |
|
97 | text_rotation=0, |
|
98 | wrap_text=True, |
|
99 | shrink_to_fit=False, |
|
100 | indent=0) |
|
101 | c_c_alignment = Alignment(vertical='center', |
|
102 | horizontal='center', |
|
103 | text_rotation=0, |
|
104 | wrap_text=True, |
|
105 | shrink_to_fit=False, |
|
106 | indent=0) |
|
107 | b_r_alignment = Alignment(vertical='bottom', |
|
108 | horizontal='right', |
|
109 | text_rotation=0, |
|
110 | wrap_text=True, |
|
111 | shrink_to_fit=False, |
|
112 | indent=0) |
|
113 | ||
114 | # Img |
|
115 | img = Image("excelexporters/myems.png") |
|
116 | ws.add_image(img, 'A1') |
|
117 | ||
118 | # Title |
|
119 | ws['B3'].alignment = b_r_alignment |
|
120 | ws['B3'] = _('Space') + ':' |
|
121 | ws['C3'].border = b_border |
|
122 | ws['C3'].alignment = b_c_alignment |
|
123 | ws['C3'] = space_name |
|
124 | ||
125 | ws['B4'].alignment = b_r_alignment |
|
126 | ws['B4'] = _('Reporting Start Datetime') + ':' |
|
127 | ws['C4'].border = b_border |
|
128 | ws['C4'].alignment = b_c_alignment |
|
129 | ws['C4'] = reporting_start_datetime_local |
|
130 | ||
131 | ws['B5'].alignment = b_r_alignment |
|
132 | ws['B5'] = _('Reporting End Datetime') + ':' |
|
133 | ws['C5'].border = b_border |
|
134 | ws['C5'].alignment = b_c_alignment |
|
135 | ws['C5'] = reporting_end_datetime_local |
|
136 | ||
137 | # Title |
|
138 | ws['B6'].border = f_border |
|
139 | ws['B6'].font = name_font |
|
140 | ws['B6'].alignment = c_c_alignment |
|
141 | ws['B6'].fill = table_fill |
|
142 | ws['B6'] = _('Name') |
|
143 | ||
144 | ws['C6'].border = f_border |
|
145 | ws['C6'].alignment = c_c_alignment |
|
146 | ws['C6'].font = name_font |
|
147 | ws['C6'].fill = table_fill |
|
148 | ws['C6'] = _('Space') |
|
149 | ||
150 | ca_len = len(report['energycategories']) |
|
151 | ||
152 | for i in range(0, ca_len): |
|
153 | col = chr(ord('D') + i) |
|
154 | ws[col + '6'].fill = table_fill |
|
155 | ws[col + '6'].font = name_font |
|
156 | ws[col + '6'].alignment = c_c_alignment |
|
157 | ws[col + '6'] = report['energycategories'][i]['name'] + \ |
|
158 | " (" + report['energycategories'][i]['unit_of_measure'] + ")" |
|
159 | ws[col + '6'].border = f_border |
|
160 | ||
161 | current_row_number = 7 |
|
162 | for i in range(0, len(report['shopfloors'])): |
|
163 | ||
164 | ws['B' + str(current_row_number)].font = title_font |
|
165 | ws['B' + str(current_row_number)].border = f_border |
|
166 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
167 | ws['B' + str(current_row_number)] = report['shopfloors'][i]['shopfloor_name'] |
|
168 | ||
169 | ws['C' + str(current_row_number)].font = title_font |
|
170 | ws['C' + str(current_row_number)].border = f_border |
|
171 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
172 | ws['C' + str(current_row_number)] = report['shopfloors'][i]['space_name'] |
|
173 | ||
174 | ca_len = len(report['shopfloors'][i]['values']) |
|
175 | for j in range(0, ca_len): |
|
176 | col = chr(ord('D') + j) |
|
177 | ws[col + str(current_row_number)].font = data_font |
|
178 | ws[col + str(current_row_number)].border = f_border |
|
179 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
180 | ws[col + str(current_row_number)] = round2(report['shopfloors'][i]['values'][j], 2) |
|
181 | ||
182 | current_row_number += 1 |
|
183 | ||
184 | filename = str(uuid.uuid4()) + '.xlsx' |
|
185 | wb.save(filename) |
|
186 | ||
187 | return filename |
|
188 |
@@ 54-187 (lines=134) @@ | ||
51 | return base64_message |
|
52 | ||
53 | ||
54 | def generate_excel(report, space_name, reporting_start_datetime_local, reporting_end_datetime_local, language): |
|
55 | ||
56 | trans = get_translation(language) |
|
57 | trans.install() |
|
58 | _ = trans.gettext |
|
59 | ||
60 | wb = Workbook() |
|
61 | ws = wb.active |
|
62 | ws.title = "CombinedEquipmentBatch" |
|
63 | ||
64 | # Row height |
|
65 | ws.row_dimensions[1].height = 102 |
|
66 | for i in range(2, 5 + 1): |
|
67 | ws.row_dimensions[i].height = 42 |
|
68 | ||
69 | for i in range(6, len(report['combined_equipments']) + 15): |
|
70 | ws.row_dimensions[i].height = 60 |
|
71 | ||
72 | # Col width |
|
73 | ws.column_dimensions['A'].width = 1.5 |
|
74 | ||
75 | ws.column_dimensions['B'].width = 25.0 |
|
76 | ||
77 | for i in range(ord('C'), ord('L')): |
|
78 | ws.column_dimensions[chr(i)].width = 15.0 |
|
79 | ||
80 | # Font |
|
81 | name_font = Font(name='Arial', size=15, bold=True) |
|
82 | title_font = Font(name='Arial', size=15, bold=True) |
|
83 | data_font = Font(name='Franklin Gothic Book', size=11) |
|
84 | ||
85 | table_fill = PatternFill(fill_type='solid', fgColor='90ee90') |
|
86 | f_border = Border(left=Side(border_style='medium'), |
|
87 | right=Side(border_style='medium'), |
|
88 | bottom=Side(border_style='medium'), |
|
89 | top=Side(border_style='medium') |
|
90 | ) |
|
91 | b_border = Border( |
|
92 | bottom=Side(border_style='medium'), |
|
93 | ) |
|
94 | ||
95 | b_c_alignment = Alignment(vertical='bottom', |
|
96 | horizontal='center', |
|
97 | text_rotation=0, |
|
98 | wrap_text=True, |
|
99 | shrink_to_fit=False, |
|
100 | indent=0) |
|
101 | c_c_alignment = Alignment(vertical='center', |
|
102 | horizontal='center', |
|
103 | text_rotation=0, |
|
104 | wrap_text=True, |
|
105 | shrink_to_fit=False, |
|
106 | indent=0) |
|
107 | b_r_alignment = Alignment(vertical='bottom', |
|
108 | horizontal='right', |
|
109 | text_rotation=0, |
|
110 | wrap_text=True, |
|
111 | shrink_to_fit=False, |
|
112 | indent=0) |
|
113 | ||
114 | # Img |
|
115 | img = Image("excelexporters/myems.png") |
|
116 | ws.add_image(img, 'A1') |
|
117 | ||
118 | # Title |
|
119 | ws['B3'].alignment = b_r_alignment |
|
120 | ws['B3'] = _('Space') + ':' |
|
121 | ws['C3'].border = b_border |
|
122 | ws['C3'].alignment = b_c_alignment |
|
123 | ws['C3'] = space_name |
|
124 | ||
125 | ws['B4'].alignment = b_r_alignment |
|
126 | ws['B4'] = _('Reporting Start Datetime') + ':' |
|
127 | ws['C4'].border = b_border |
|
128 | ws['C4'].alignment = b_c_alignment |
|
129 | ws['C4'] = reporting_start_datetime_local |
|
130 | ||
131 | ws['B5'].alignment = b_r_alignment |
|
132 | ws['B5'] = _('Reporting End Datetime') + ':' |
|
133 | ws['C5'].border = b_border |
|
134 | ws['C5'].alignment = b_c_alignment |
|
135 | ws['C5'] = reporting_end_datetime_local |
|
136 | ||
137 | # Title |
|
138 | ws['B6'].border = f_border |
|
139 | ws['B6'].font = name_font |
|
140 | ws['B6'].alignment = c_c_alignment |
|
141 | ws['B6'].fill = table_fill |
|
142 | ws['B6'] = _('Name') |
|
143 | ||
144 | ws['C6'].border = f_border |
|
145 | ws['C6'].alignment = c_c_alignment |
|
146 | ws['C6'].font = name_font |
|
147 | ws['C6'].fill = table_fill |
|
148 | ws['C6'] = _('Space') |
|
149 | ||
150 | ca_len = len(report['energycategories']) |
|
151 | ||
152 | for i in range(0, ca_len): |
|
153 | col = chr(ord('D') + i) |
|
154 | ws[col + '6'].fill = table_fill |
|
155 | ws[col + '6'].font = name_font |
|
156 | ws[col + '6'].alignment = c_c_alignment |
|
157 | ws[col + '6'] = report['energycategories'][i]['name'] + \ |
|
158 | " (" + report['energycategories'][i]['unit_of_measure'] + ")" |
|
159 | ws[col + '6'].border = f_border |
|
160 | ||
161 | current_row_number = 7 |
|
162 | for i in range(0, len(report['combined_equipments'])): |
|
163 | ||
164 | ws['B' + str(current_row_number)].font = title_font |
|
165 | ws['B' + str(current_row_number)].border = f_border |
|
166 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
167 | ws['B' + str(current_row_number)] = report['combined_equipments'][i]['combined_equipment_name'] |
|
168 | ||
169 | ws['C' + str(current_row_number)].font = title_font |
|
170 | ws['C' + str(current_row_number)].border = f_border |
|
171 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
172 | ws['C' + str(current_row_number)] = report['combined_equipments'][i]['space_name'] |
|
173 | ||
174 | ca_len = len(report['combined_equipments'][i]['values']) |
|
175 | for j in range(0, ca_len): |
|
176 | col = chr(ord('D') + j) |
|
177 | ws[col + str(current_row_number)].font = data_font |
|
178 | ws[col + str(current_row_number)].border = f_border |
|
179 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
180 | ws[col + str(current_row_number)] = round2(report['combined_equipments'][i]['values'][j], 2) |
|
181 | ||
182 | current_row_number += 1 |
|
183 | ||
184 | filename = str(uuid.uuid4()) + '.xlsx' |
|
185 | wb.save(filename) |
|
186 | ||
187 | return filename |
|
188 |
@@ 54-185 (lines=132) @@ | ||
51 | return base64_message |
|
52 | ||
53 | ||
54 | def generate_excel(report, space_name, reporting_start_datetime_local, reporting_end_datetime_local, language): |
|
55 | trans = get_translation(language) |
|
56 | trans.install() |
|
57 | _ = trans.gettext |
|
58 | wb = Workbook() |
|
59 | ws = wb.active |
|
60 | ws.title = "EquipmentBatch" |
|
61 | ||
62 | # Row height |
|
63 | ws.row_dimensions[1].height = 102 |
|
64 | for i in range(2, 5 + 1): |
|
65 | ws.row_dimensions[i].height = 42 |
|
66 | ||
67 | for i in range(6, len(report['equipments']) + 15): |
|
68 | ws.row_dimensions[i].height = 60 |
|
69 | ||
70 | # Col width |
|
71 | ws.column_dimensions['A'].width = 1.5 |
|
72 | ||
73 | ws.column_dimensions['B'].width = 25.0 |
|
74 | ||
75 | for i in range(ord('C'), ord('L')): |
|
76 | ws.column_dimensions[chr(i)].width = 15.0 |
|
77 | ||
78 | # Font |
|
79 | name_font = Font(name='Arial', size=15, bold=True) |
|
80 | title_font = Font(name='Arial', size=15, bold=True) |
|
81 | data_font = Font(name='Franklin Gothic Book', size=11) |
|
82 | ||
83 | table_fill = PatternFill(fill_type='solid', fgColor='90ee90') |
|
84 | f_border = Border(left=Side(border_style='medium'), |
|
85 | right=Side(border_style='medium'), |
|
86 | bottom=Side(border_style='medium'), |
|
87 | top=Side(border_style='medium') |
|
88 | ) |
|
89 | b_border = Border( |
|
90 | bottom=Side(border_style='medium'), |
|
91 | ) |
|
92 | ||
93 | b_c_alignment = Alignment(vertical='bottom', |
|
94 | horizontal='center', |
|
95 | text_rotation=0, |
|
96 | wrap_text=True, |
|
97 | shrink_to_fit=False, |
|
98 | indent=0) |
|
99 | c_c_alignment = Alignment(vertical='center', |
|
100 | horizontal='center', |
|
101 | text_rotation=0, |
|
102 | wrap_text=True, |
|
103 | shrink_to_fit=False, |
|
104 | indent=0) |
|
105 | b_r_alignment = Alignment(vertical='bottom', |
|
106 | horizontal='right', |
|
107 | text_rotation=0, |
|
108 | wrap_text=True, |
|
109 | shrink_to_fit=False, |
|
110 | indent=0) |
|
111 | ||
112 | # Img |
|
113 | img = Image("excelexporters/myems.png") |
|
114 | ws.add_image(img, 'A1') |
|
115 | ||
116 | # Title |
|
117 | ws['B3'].alignment = b_r_alignment |
|
118 | ws['B3'] = _('Space') + ':' |
|
119 | ws['C3'].border = b_border |
|
120 | ws['C3'].alignment = b_c_alignment |
|
121 | ws['C3'] = space_name |
|
122 | ||
123 | ws['B4'].alignment = b_r_alignment |
|
124 | ws['B4'] = _('Reporting Start Datetime') + ':' |
|
125 | ws['C4'].border = b_border |
|
126 | ws['C4'].alignment = b_c_alignment |
|
127 | ws['C4'] = reporting_start_datetime_local |
|
128 | ||
129 | ws['B5'].alignment = b_r_alignment |
|
130 | ws['B5'] = _('Reporting End Datetime') + ':' |
|
131 | ws['C5'].border = b_border |
|
132 | ws['C5'].alignment = b_c_alignment |
|
133 | ws['C5'] = reporting_end_datetime_local |
|
134 | ||
135 | # Title |
|
136 | ws['B6'].border = f_border |
|
137 | ws['B6'].font = name_font |
|
138 | ws['B6'].alignment = c_c_alignment |
|
139 | ws['B6'].fill = table_fill |
|
140 | ws['B6'] = _('Name') |
|
141 | ||
142 | ws['C6'].border = f_border |
|
143 | ws['C6'].alignment = c_c_alignment |
|
144 | ws['C6'].font = name_font |
|
145 | ws['C6'].fill = table_fill |
|
146 | ws['C6'] = _('Space') |
|
147 | ||
148 | ca_len = len(report['energycategories']) |
|
149 | ||
150 | for i in range(0, ca_len): |
|
151 | col = chr(ord('D') + i) |
|
152 | ws[col + '6'].fill = table_fill |
|
153 | ws[col + '6'].font = name_font |
|
154 | ws[col + '6'].alignment = c_c_alignment |
|
155 | ws[col + '6'] = report['energycategories'][i]['name'] + \ |
|
156 | " (" + report['energycategories'][i]['unit_of_measure'] + ")" |
|
157 | ws[col + '6'].border = f_border |
|
158 | ||
159 | current_row_number = 7 |
|
160 | for i in range(0, len(report['equipments'])): |
|
161 | ||
162 | ws['B' + str(current_row_number)].font = title_font |
|
163 | ws['B' + str(current_row_number)].border = f_border |
|
164 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
165 | ws['B' + str(current_row_number)] = report['equipments'][i]['equipment_name'] |
|
166 | ||
167 | ws['C' + str(current_row_number)].font = title_font |
|
168 | ws['C' + str(current_row_number)].border = f_border |
|
169 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
170 | ws['C' + str(current_row_number)] = report['equipments'][i]['space_name'] |
|
171 | ||
172 | ca_len = len(report['equipments'][i]['values']) |
|
173 | for j in range(0, ca_len): |
|
174 | col = chr(ord('D') + j) |
|
175 | ws[col + str(current_row_number)].font = data_font |
|
176 | ws[col + str(current_row_number)].border = f_border |
|
177 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
178 | ws[col + str(current_row_number)] = round2(report['equipments'][i]['values'][j], 2) |
|
179 | ||
180 | current_row_number += 1 |
|
181 | ||
182 | filename = str(uuid.uuid4()) + '.xlsx' |
|
183 | wb.save(filename) |
|
184 | ||
185 | return filename |
|
186 |