From 4762689176fbf7b8c6f97ad0af34c470c106e7d2 Mon Sep 17 00:00:00 2001 From: NikolayBorovenskiy Date: Mon, 23 Oct 2023 17:17:47 +0300 Subject: [PATCH] feat: [ZNO-2099] Word documents generate in DOCX (#19) --- .../components/Header/HeaderActionsDropdown/index.jsx | 4 ++-- superset/dashboards/data/api.py | 2 +- superset/dashboards/data/commands/export.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx index 8bd03c24ae316..81a58ab1bafa1 100644 --- a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx @@ -200,7 +200,7 @@ class HeaderActionsDropdown extends React.PureComponent { case MENU_KEYS.DOWNLOAD_AS_DOC_PORTRAIT: { exportDashboard({ formData: { id: this.props.dashboardId }, - resultFormat: 'doc', + resultFormat: 'docx', landscape: false, }); break; @@ -208,7 +208,7 @@ class HeaderActionsDropdown extends React.PureComponent { case MENU_KEYS.DOWNLOAD_AS_DOC_LANDSCAPE: { exportDashboard({ formData: { id: this.props.dashboardId }, - resultFormat: 'doc', + resultFormat: 'docx', landscape: true, }); break; diff --git a/superset/dashboards/data/api.py b/superset/dashboards/data/api.py index b58459b60c5ac..1908cf3f1e16b 100644 --- a/superset/dashboards/data/api.py +++ b/superset/dashboards/data/api.py @@ -128,5 +128,5 @@ def dispatch_export_command( """ return { "pdf": lambda: PDFExportCommand(dashboard_id, landscape), - "doc": lambda: DocExportCommand(dashboard_id, landscape), + "docx": lambda: DocExportCommand(dashboard_id, landscape), }.get(format_type, lambda: None)() diff --git a/superset/dashboards/data/commands/export.py b/superset/dashboards/data/commands/export.py index 2a2ffa0d7ca4c..160df42f33acc 100644 --- a/superset/dashboards/data/commands/export.py +++ b/superset/dashboards/data/commands/export.py @@ -63,7 +63,7 @@ def run(self) -> ExportedFile: with tempfile.NamedTemporaryFile(suffix=".pdf") as pdf_file: pdf_file.write(exported_file.content) pdf_file.seek(0) - with tempfile.NamedTemporaryFile(suffix=".doc") as doc_file: + with tempfile.NamedTemporaryFile(suffix=".docx") as doc_file: pdf2docx.parse(pdf_file.name, doc_file.name) with open(doc_file.name, mode="rb") as file_content: document_content = file_content.read()