Skip to content

Commit

Permalink
Use xltx extension for excel templates
Browse files Browse the repository at this point in the history
Suggestion from @PatLittle, does this improve behaviour in Excel?
  • Loading branch information
wardi committed Dec 13, 2024
1 parent 37bcb33 commit df273ca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ckanext/recombinant/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ def record_fail(err):
)


def _xlsx_response_headers():
def _xltx_response_headers():
"""
Returns tuple of content type and disposition type.
If the request is from MS Edge user agent, we force the XLSX
If the request is from MS Edge user agent, we force the XLTX
download to prevent Edge from cowboying into Office Apps Online
"""
content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
Expand All @@ -226,7 +226,7 @@ def _xlsx_response_headers():
return content_type, disposition_type


@recombinant.route('/recombinant-template/<dataset_type>_<lang>_<owner_org>.xlsx', methods=['GET', 'POST'])
@recombinant.route('/recombinant-template/<dataset_type>_<lang>_<owner_org>.xltx', methods=['GET', 'POST'])
def template(dataset_type, lang, owner_org):

"""
Expand Down Expand Up @@ -282,10 +282,10 @@ def template(dataset_type, lang, owner_org):
blob = BytesIO()
book.save(blob)
response = Response(blob.getvalue())
content_type, disposition_type = _xlsx_response_headers()
content_type, disposition_type = _xltx_response_headers()
response.headers['Content-Type'] = content_type
response.headers['Content-Disposition'] = (
'{}; filename="{}_{}_{}.xlsx"'.format(
'{}; filename="{}_{}_{}.xltx"'.format(
disposition_type,
dataset['owner_org'],
lang,
Expand All @@ -303,7 +303,7 @@ def _data_dictionary(dataset_type, published_resource=False):
blob = BytesIO()
book.save(blob)
response = Response(blob.getvalue())
content_type, disposition_type = _xlsx_response_headers()
content_type, disposition_type = _xltx_response_headers()
response.headers['Content-Type'] = content_type
response.headers['Content-Disposition'] = '{}; filename="{}.xlsx"'.format(
disposition_type,
Expand Down

0 comments on commit df273ca

Please sign in to comment.