From 3f0eee4b6084f337db1f41bd30afc726c0273992 Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Wed, 10 Jul 2024 21:25:10 +0200 Subject: [PATCH] [New #36] Added support for export of records with MSExcel --- src/actions/RecordsActions.js | 3 --- src/components/record/ExportRecordsDropdown.jsx | 1 - src/components/record/RecordsController.jsx | 1 + src/constants/DefaultConstants.js | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/actions/RecordsActions.js b/src/actions/RecordsActions.js index 22a77a0d..b582821b 100644 --- a/src/actions/RecordsActions.js +++ b/src/actions/RecordsActions.js @@ -61,9 +61,6 @@ export function exportRecords(exportType, params = {}) { .get(`${API_URL}/rest/records/export`, { params, paramsSerializer, - headers: { - accept: exportType.mediaType, - }, responseType: "arraybuffer", }) .then((resp) => { diff --git a/src/components/record/ExportRecordsDropdown.jsx b/src/components/record/ExportRecordsDropdown.jsx index 60bf3a73..84e29eac 100644 --- a/src/components/record/ExportRecordsDropdown.jsx +++ b/src/components/record/ExportRecordsDropdown.jsx @@ -18,7 +18,6 @@ const ExportRecordsDropdown = ({ records, onExport }) => { variant="primary" className="action-button" > - {/*Excel export is currently not supported by the backend, uncommenting for demonstration purposes*/} onExport(ExportType.EXCEL)}>{i18n("records.export.excel")} onExport(ExportType.JSON)}>{i18n("records.export.json")} diff --git a/src/components/record/RecordsController.jsx b/src/components/record/RecordsController.jsx index 0b61668c..ff626646 100644 --- a/src/components/record/RecordsController.jsx +++ b/src/components/record/RecordsController.jsx @@ -104,6 +104,7 @@ class RecordsController extends React.Component { this.props.exportRecords(exportType, { ...this.state.filters, sort: sortToParams(this.state.sort), + page: this.state.pageNumber, }), "records", ); diff --git a/src/constants/DefaultConstants.js b/src/constants/DefaultConstants.js index f0131ad8..de26bf85 100644 --- a/src/constants/DefaultConstants.js +++ b/src/constants/DefaultConstants.js @@ -106,7 +106,7 @@ export const HttpHeaders = { export const MediaType = { FORM_URLENCODED: "application/x-www-form-urlencoded", - EXCEL: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + EXCEL: "application/vnd.ms-excel", JSON: "application/json", };