|
@@ -5,11 +5,29 @@ from PySide6.QtGui import QStandardItemModel, QStandardItem
|
5
|
5
|
from PySide6.QtCore import QItemSelectionModel
|
6
|
6
|
|
7
|
7
|
|
8
|
|
-def main_function(ui, db_path, utf_en):
|
|
8
|
+def process_utf_en(utf_en):
|
9
|
9
|
# 确保 utf_en 是字节字符串
|
10
|
10
|
if not isinstance(utf_en, bytes):
|
11
|
11
|
utf_en = utf_en.encode('utf-8')
|
12
|
12
|
|
|
13
|
+ # 将字节字符串解码为普通字符串
|
|
14
|
+ file_name = utf_en.decode('utf-8')
|
|
15
|
+
|
|
16
|
+ # 检查文件后缀名并进行相应处理
|
|
17
|
+ if file_name.endswith('.xls'):
|
|
18
|
+ # 去掉 .xls 后缀并添加 .xlsx 后缀
|
|
19
|
+ file_name = file_name[:-4] + '.xlsx'
|
|
20
|
+
|
|
21
|
+ # 将处理后的字符串重新编码为字节字符串
|
|
22
|
+ utf_en = file_name.encode('utf-8')
|
|
23
|
+
|
|
24
|
+ return utf_en
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+def main_function(ui, db_path, utf_en):
|
|
28
|
+ # 处理 utf_en
|
|
29
|
+ utf_en = process_utf_en(utf_en)
|
|
30
|
+
|
13
|
31
|
# 设置 QTabWidget 的可见性和标签文本
|
14
|
32
|
tabs_to_show = [(0, '水准测段高差计算成果表')]
|
15
|
33
|
for index in range(ui.tabWidget.count()):
|
|
@@ -53,7 +71,8 @@ def main_function(ui, db_path, utf_en):
|
53
|
71
|
model.setHorizontalHeaderLabels(headers)
|
54
|
72
|
|
55
|
73
|
# 使用 itertools.zip_longest 处理长度不一致的情况
|
56
|
|
- for row_data, correct_factor_data in itertools.zip_longest(output_result, correct_factor_result, fillvalue=(None, None)):
|
|
74
|
+ for row_data, correct_factor_data in itertools.zip_longest(output_result, correct_factor_result,
|
|
75
|
+ fillvalue=(None, None)):
|
57
|
76
|
items = []
|
58
|
77
|
for i, item in enumerate(row_data):
|
59
|
78
|
if item is None:
|
|
@@ -142,7 +161,8 @@ def search_show_function(ui, db_path, utf_en):
|
142
|
161
|
input_model.setHorizontalHeaderLabels(input_headers)
|
143
|
162
|
|
144
|
163
|
# 使用 itertools.zip_longest 处理长度不一致的情况
|
145
|
|
- for row_data, param_data in itertools.zip_longest(input_result, param_result, fillvalue=(None, None, None, None, None, None, None, None, None)):
|
|
164
|
+ for row_data, param_data in itertools.zip_longest(input_result, param_result,
|
|
165
|
+ fillvalue=(None, None, None, None, None, None, None, None, None)):
|
146
|
166
|
items = []
|
147
|
167
|
for i, item in enumerate(row_data):
|
148
|
168
|
if item is None:
|
|
@@ -235,7 +255,8 @@ def search_show_function(ui, db_path, utf_en):
|
235
|
255
|
output_model.setHorizontalHeaderLabels(output_headers)
|
236
|
256
|
|
237
|
257
|
# 使用 itertools.zip_longest 处理长度不一致的情况
|
238
|
|
- for row_data, correct_factor_data in itertools.zip_longest(output_result, correct_factor_result, fillvalue=(None, None)):
|
|
258
|
+ for row_data, correct_factor_data in itertools.zip_longest(output_result, correct_factor_result,
|
|
259
|
+ fillvalue=(None, None)):
|
239
|
260
|
items = []
|
240
|
261
|
for i, item in enumerate(row_data):
|
241
|
262
|
if item is None:
|
|
@@ -283,4 +304,3 @@ def search_show_function(ui, db_path, utf_en):
|
283
|
304
|
|
284
|
305
|
# 隐藏 QLabel
|
285
|
306
|
ui.default_remind1.hide()
|
286
|
|
-
|