diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx index af59b26f5af..30800bec468 100644 --- a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx +++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx @@ -264,7 +264,7 @@ test('Should export to pivoted Excel if report is pivot table', async () => { userEvent.click(await screen.findByText('Export to Pivoted Excel')); expect(props.exportPivotExcel).toHaveBeenCalledTimes(1); expect(props.exportPivotExcel).toHaveBeenCalledWith( - '.pvtTable', + '#chart-id-371 .pvtTable', props.slice.slice_name, ); }); diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx index 2dcc08966d3..08768740742 100644 --- a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx +++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx @@ -271,7 +271,11 @@ const SliceHeaderControls = ( break; } case MenuKeys.ExportPivotXlsx: { - props.exportPivotExcel?.('.pvtTable', props.slice.slice_name); + const sliceSelector = `#chart-id-${props.slice.slice_id}`; + props.exportPivotExcel?.( + `${sliceSelector} .pvtTable`, + props.slice.slice_name, + ); break; } case MenuKeys.CrossFilterScoping: { diff --git a/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx b/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx index 40fdd29460e..19278a747b9 100644 --- a/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx +++ b/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx @@ -333,8 +333,9 @@ export const useExploreAdditionalActionsMenu = ( icon: , disabled: !canDownloadCSV, onClick: () => { + const sliceSelector = `#chart-id-${slice?.slice_id}`; exportPivotExcel( - '.pvtTable', + `${sliceSelector} .pvtTable`, slice?.slice_name ?? t('pivoted_xlsx'), ); setIsDropdownVisible(false);