Explorar el Código

250117-3代码。

baoyubo hace 4 meses
padre
commit
b8c9f62de7
Se han modificado 1 ficheros con 7 adiciones y 3 borrados
  1. 7 3
      routers/api/ThreeProofingResponsible/person.py

+ 7 - 3
routers/api/ThreeProofingResponsible/person.py

@@ -510,11 +510,15 @@ def other_type_string_type_parent_id_create_data(db,string,type_parent_id,file_i
             return reslte ,False
     return reslte ,True
 def import_data(db,file_path,user_id,file_info):
-    book = xlrd.open_workbook(file_path)
-    sheet = book.sheet_by_index(0)
 
-    data = []
     import_status = True
+    try:
+        book = xlrd.open_workbook(file_path)
+        sheet = book.sheet_by_index(0)
+    except :
+        file_info.remark = file_info.remark + f'\n文件打开失败,请核实文件格式为xlsx/xlx>'
+        import_status = False
+    data = []
     for row in range(4, sheet.nrows):
         # 姓名
         name = sheet.cell(row, 0).value