Merge pull request 'gentil message sur erreur d import esxcel' (#131) from jmplace/ScoDoc-Lille:import_excel_errmsg into master

Reviewed-on: viennet/ScoDoc#131
This commit is contained in:
Emmanuel Viennet 2021-09-21 16:50:45 +02:00
commit ae51e4c17a
1 changed files with 15 additions and 3 deletions

View File

@ -563,12 +563,24 @@ def excel_feuille_saisie(e, titreannee, description, lines):
def excel_bytes_to_list(bytes_content):
filelike = io.BytesIO(bytes_content)
return _excel_to_list(filelike)
try:
filelike = io.BytesIO(bytes_content)
return _excel_to_list(filelike)
except:
raise ScoValueError("""
scolars_import_excel_file: un contenu xlsx semble corrompu!
peut-être avez vous fourni un fichier au mauvais format (txt, xls, ..)
""")
def excel_file_to_list(filename):
return _excel_to_list(filename)
try:
return _excel_to_list(filename)
except:
raise ScoValueError("""
scolars_import_excel_file: un contenu xlsx semble corrompu!
peut-être avez vous fourni un fichier au mauvais format (txt, xls, ..)
""")
def _excel_to_list(filelike): # we may need 'encoding' argument ?