You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "EugeneTorap (via GitHub)" <gi...@apache.org> on 2023/01/27 14:48:15 UTC

[GitHub] [superset] EugeneTorap commented on a diff in pull request #22006: feat: Add excel export

EugeneTorap commented on code in PR #22006:
URL: https://github.com/apache/superset/pull/22006#discussion_r1089045665


##########
superset/common/query_context_processor.py:
##########
@@ -446,15 +446,20 @@ def processing_time_offsets(  # pylint: disable=too-many-locals,too-many-stateme
         return CachedTimeOffset(df=rv_df, queries=queries, cache_keys=cache_keys)
 
     def get_data(self, df: pd.DataFrame) -> Union[str, List[Dict[str, Any]]]:
-        if self._query_context.result_format == ChartDataResultFormat.CSV:
+        if self._query_context.result_format in ChartDataResultFormat.table_like():
             include_index = not isinstance(df.index, pd.RangeIndex)
             columns = list(df.columns)
             verbose_map = self._qc_datasource.data.get("verbose_map", {})
             if verbose_map:
                 df.columns = [verbose_map.get(column, column) for column in columns]
-            result = csv.df_to_escaped_csv(
-                df, index=include_index, **config["CSV_EXPORT"]
-            )
+
+            result = None
+            if self._query_context.result_format == ChartDataResultFormat.CSV:
+                result = csv.df_to_escaped_csv(
+                    df, index=include_index, **config["CSV_EXPORT"]
+                )
+            elif self._query_context.result_format == ChartDataResultFormat.XLSX:
+                result = excel.df_to_excel(df, **config["EXCEL_EXPORT"])

Review Comment:
   At the moment yes, we do the same like for CSV!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org