Skip to content

Commit

Permalink
feat: [ZNO-2099] Word documents generate in DOCX (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayBorovenskiy authored Oct 23, 2023
1 parent 5a64aee commit 4762689
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ 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;
}
case MENU_KEYS.DOWNLOAD_AS_DOC_LANDSCAPE: {
exportDashboard({
formData: { id: this.props.dashboardId },
resultFormat: 'doc',
resultFormat: 'docx',
landscape: true,
});
break;
Expand Down
2 changes: 1 addition & 1 deletion superset/dashboards/data/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)()
2 changes: 1 addition & 1 deletion superset/dashboards/data/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4762689

Please sign in to comment.