GitHub user dosubot[bot] added a comment to the discussion: download as pivoted excel in custom pivot plugin
<!-- Answer --> The "download as pivoted excel/CSV" functionality in Superset is **hardcoded** for specific viz types—it's not automatically inherited by custom plugins. Your `'smsrc-custom-pivot'` doesn't show the option because the UI checks for specific viz_type strings. To enable pivoted downloads for your custom plugin, you'll need to modify Superset's core code in **three places**: **1. Frontend - Export Menu** ([useExploreAdditionalActionsMenu/index.jsx](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx#L72)) Add your viz_type to the `VIZ_TYPES_PIVOTABLE` array: ```javascript const VIZ_TYPES_PIVOTABLE = [ VizType.PivotTable, 'smsrc-custom-pivot', // Add your custom viz_type ]; ``` **2. Frontend - Dashboard Export** ([SliceHeaderControls/index.tsx](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx#L456-L462)) Update the pivot table check to include your viz_type: ```typescript const isPivotTable = slice.viz_type === VizType.PivotTable || slice.viz_type === 'smsrc-custom-pivot'; ``` **3. Backend - Post Processor** ([client_processing.py](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/client_processing.py#L305-L308)) Register your viz_type in the `post_processors` dictionary: ```python post_processors = { "pivot_table_v2": pivot_table_v2, "table": table, "smsrc-custom-pivot": pivot_table_v2, # Reuse existing logic if your data structure matches } ``` If your custom pivot uses the same data structure as the default pivot table, you can reuse the `pivot_table_v2` post-processor. Otherwise, you'll need to implement a custom transformation function. Unfortunately, there's no plugin metadata or `Behavior` property to enable this declaratively—the export functionality is currently tied to hardcoded viz_type checks. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/30986f2c-49d2-4d2c-95a8-dd610cb34b8a?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/30986f2c-49d2-4d2c-95a8-dd610cb34b8a?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/30986f2c-49d2-4d2c-95a8-dd610cb34b8a?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/30986f2c-49d2-4d2c-95a8-dd610cb34b8a?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/30986f2c-49d2-4d 2c-95a8-dd610cb34b8a?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/30986f2c-49d2-4d2c-95a8-dd610cb34b8a?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/30986f2c-49d2-4d2c-95a8-dd610cb34b8a?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge) [](https://cursor.com/link/prompt?text=The%20%22download%20as%20pivoted%20excel/CSV%22%20functionality%20in%20Superset%20is%20%2A%2Ahardcoded%2A%2A%20for%20specific%20viz%20types%E2%80%94it%27s%20not%20automatically%20inherited%20by%20custom%20plugins.%20Your%20%60%27smsrc-custom-pivot%27%60%20doesn%27t%20show%20the%20option%20because%20the%20UI%20checks%20for%20specific%20viz_type%20strings.%0A%0ATo%20enable%20pivoted%20downloads%20for%20your%20custom%20plugin%2C%20you%27ll%20need%20to%20modify%20Superset%27s%20core%20code%20in%20%2A%2Athree%20places%2A%2A%3A%0A%0A%2A%2A1.%20Frontend%20-%20Export%20Menu%2A%2A%20%28%5BuseExploreAdditionalActionsMenu/index.jsx%5D%28https%3A//github.com/apache/superset/blob/829e4d92d 91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx%23L72%29%29%0A%0AAdd%20your%20viz_type%20to%20the%20%60VIZ_TYPES_PIVOTABLE%60%20array%3A%0A%60%60%60javascript%0Aconst%20VIZ_TYPES_PIVOTABLE%20%3D%20%5B%0A%20%20VizType.PivotTable%2C%0A%20%20%27smsrc-custom-pivot%27%2C%20%20//%20Add%20your%20custom%20viz_type%0A%5D%3B%0A%60%60%60%0A%0A%2A%2A2.%20Frontend%20-%20Dashboard%20Export%2A%2A%20%28%5BSliceHeaderControls/index.tsx%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx%23L456-L462%29%29%0A%0AUpdate%20the%20pivot%20table%20check%20to%20include%20your%20viz_type%3A%0A%60%60%60typescript%0Aconst%20isPivotTable%20%3D%20slice.viz_type%20%3D%3D%3D%20VizType.PivotTable%20%7C%7C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20slice.viz_type%20%3D%3D%3D%20%27smsrc-custom-pivot%27%3B%0A%60%60%60%0A% 0A%2A%2A3.%20Backend%20-%20Post%20Processor%2A%2A%20%28%5Bclient_processing.py%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/client_processing.py%23L305-L308%29%29%0A%0ARegister%20your%20viz_type%20in%20the%20%60post_processors%60%20dictionary%3A%0A%60%60%60python%0Apost_processors%20%3D%20%7B%0A%20%20%20%20%22pivot_table_v2%22%3A%20pivot_table_v2%2C%0A%20%20%20%20%22table%22%3A%20table%2C%0A%20%20%20%20%22smsrc-custom-pivot%22%3A%20pivot_table_v2%2C%20%20%23%20Reuse%20existing%20logic%20if%20your%20data%20structure%20matches%0A%7D%0A%60%60%60%0A%0AIf%20your%20custom%20pivot%20uses%20the%20same%20data%20structure%20as%20the%20default%20pivot%20table%2C%20you%20can%20reuse%20the%20%60pivot_table_v2%60%20post-processor.%20Otherwise%2C%20you%27ll%20need%20to%20implement%20a%20custom%20transformation%20function.%0A%0AUnfortunately%2C%20there%27s%20no%20plugin%20metadata%20or%20%60Behavior%60%20property%20to%20enable%20this%20decl aratively%E2%80%94the%20export%20functionality%20is%20currently%20tied%20to%20hardcoded%20viz_type%20checks.) [](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/38577) GitHub link: https://github.com/apache/superset/discussions/38577#discussioncomment-16082222 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
