mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-10 11:24:10 -04:00
Merge pull request #4244 from alphagov/xlrd-2
Upgrade xlrd to version 2 and force `.xlsm` files to open with pyexcel-xlsx instead
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -105,7 +105,7 @@ lml==0.1.0
|
||||
# via
|
||||
# pyexcel
|
||||
# pyexcel-io
|
||||
lxml==4.6.5
|
||||
lxml==4.8.0
|
||||
# via
|
||||
# pyexcel-ezodf
|
||||
# pyexcel-ods3
|
||||
@@ -119,7 +119,7 @@ notifications-python-client==6.3.0
|
||||
# via -r requirements.in
|
||||
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@55.1.6
|
||||
# via -r requirements.in
|
||||
openpyxl==3.0.7
|
||||
openpyxl==3.0.9
|
||||
# via pyexcel-xlsx
|
||||
orderedset==2.0.3
|
||||
# via notifications-utils
|
||||
@@ -205,7 +205,7 @@ smartypants==2.0.1
|
||||
# via notifications-utils
|
||||
statsd==3.3.0
|
||||
# via notifications-utils
|
||||
texttable==1.6.3
|
||||
texttable==1.6.4
|
||||
# via pyexcel
|
||||
urllib3==1.26.5
|
||||
# via
|
||||
@@ -222,7 +222,7 @@ wtforms==3.0.1
|
||||
# via
|
||||
# -r requirements.in
|
||||
# flask-wtf
|
||||
xlrd==1.2.0
|
||||
xlrd==2.0.1
|
||||
# via pyexcel-xls
|
||||
xlwt==1.3.0
|
||||
# via pyexcel-xls
|
||||
|
||||
Reference in New Issue
Block a user