diff --git a/app/models/spreadsheet.py b/app/models/spreadsheet.py index 7b66a7b0f..59ca2bdd7 100644 --- a/app/models/spreadsheet.py +++ b/app/models/spreadsheet.py @@ -3,6 +3,7 @@ from io import StringIO from os import path import pyexcel +import pyexcel_xlsx class Spreadsheet(): @@ -72,6 +73,15 @@ class Spreadsheet(): file_content = StringIO( Spreadsheet.normalise_newlines(file_content)) + if extension == 'xlsm': + file_data = pyexcel_xlsx.get_data(file_content) + instance = cls.from_rows( + # Get the first sheet from the workbook + list(file_data.values())[0], + filename, + ) + return instance + instance = cls.from_rows( pyexcel.iget_array( file_type=extension, diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 7d192f2a0..3dda1a696 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -300,8 +300,8 @@ def test_set_sender_redirects_if_one_sms_sender( def test_that_test_files_exist(): - assert len(test_spreadsheet_files) == 7 - assert len(test_non_spreadsheet_files) == 7 + assert len(test_spreadsheet_files) == 8 + assert len(test_non_spreadsheet_files) == 6 def test_should_not_allow_files_to_be_uploaded_without_the_correct_permission( diff --git a/tests/non_spreadsheet_files/excel 2007 with macro support.xlsm b/tests/spreadsheet_files/excel 2007 with macro support.xlsm similarity index 100% rename from tests/non_spreadsheet_files/excel 2007 with macro support.xlsm rename to tests/spreadsheet_files/excel 2007 with macro support.xlsm