Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion spp_area_base/models/area_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ def import_data(self):
_logger.info("Area Import: Loading Excel File: %s" % fields.Datetime.now())
# Wrap binary to BytesIO

book = self._get_book()
# Check if file is valid
if self.excel_file:
try:
book = self._get_book()
except Exception as e:
raise ValidationError(_("Unsupported file format. Only .xlsx files are accepted.")) from e

sheet_names = book.sheet_names()
sheet_names.sort()
Expand Down
Loading