Replies: 3 comments 6 replies
-
Hey there, @ambarishp! I'm here to help you with any issues or questions you may have. Let's tackle this together! Yes, there is an option to remove a specific column containing HTML tags from being included in the exported Excel or CSV file in Apache Superset version 4.0.1. You can achieve this by filtering out the column in the Here is the relevant part of the code where you can filter out the column: export const useTableColumns = (
colnames?: string[],
coltypes?: GenericDataType[],
data?: Record<string, any>[],
datasourceId?: string,
isVisible?: boolean,
moreConfigs?: { [key: string]: Partial<Column> },
allowHTML?: boolean,
) => {
const [originalFormattedTimeColumns, setOriginalFormattedTimeColumns] =
useState<string[]>(getTimeColumns(datasourceId));
const onTimeColumnChange = (
columnName: string,
columnType: FormatPickerValue,
) => {
if (!datasourceId) {
return;
}
if (
columnType === FormatPickerValue.Original &&
!originalFormattedTimeColumns.includes(columnName)
) {
const cols = getTimeColumns(datasourceId);
cols.push(columnName);
setTimeColumns(datasourceId, cols);
setOriginalFormattedTimeColumns(cols);
} else if (
columnType === FormatPickerValue.Formatted &&
originalFormattedTimeColumns.includes(columnName)
) {
const cols = getTimeColumns(datasourceId);
cols.splice(cols.indexOf(columnName), 1);
setTimeColumns(datasourceId, cols);
setOriginalFormattedTimeColumns(cols);
}
};
useEffect(() => {
if (isVisible) {
setOriginalFormattedTimeColumns(getTimeColumns(datasourceId));
}
}, [datasourceId, isVisible]);
return useMemo(
() =>
colnames && data?.length
? colnames
.filter((column: string) => Object.keys(data[0]).includes(column))
.filter((column: string) => column !== 'column_with_html_tags') // Add this line to filter out the specific column
.map((key, index) => {
const colType = coltypes?.[index];
const firstValue = data[0][key];
const originalFormattedTimeColumnIndex =
colType === GenericDataType.Temporal
? originalFormattedTimeColumns.indexOf(key)
: -1;
const isOriginalTimeColumn =
originalFormattedTimeColumns.includes(key);
return {
// react-table requires a non-empty id, therefore we introduce a fallback value in case the key is empty
id: key || index,
accessor: row => row[key],
Header:
colType === GenericDataType.Temporal &&
typeof firstValue !== 'string' ? (
<DataTableTemporalHeaderCell
columnName={key}
datasourceId={datasourceId}
onTimeColumnChange={onTimeColumnChange}
isOriginalTimeColumn={isOriginalTimeColumn}
/>
) : (
key
),
Cell: ({ value }) => {
if (value === true) {
return BOOL_TRUE_DISPLAY;
}
if (value === false) {
return BOOL_FALSE_DISPLAY;
}
if (value === null) {
return <CellNull>{NULL_DISPLAY}</CellNull>;
}
if (
colType === GenericDataType.Temporal &&
originalFormattedTimeColumnIndex === -1 &&
typeof value === 'number'
) {
return timeFormatter(value);
}
if (typeof value === 'string' && allowHTML) {
return safeHtmlSpan(value);
}
return String(value);
},
...moreConfigs?.[key],
} as Column;
})
: [],
[
colnames,
data,
coltypes,
datasourceId,
moreConfigs,
originalFormattedTimeColumns,
],
);
}; In the above code, replace |
Beta Was this translation helpful? Give feedback.
-
I m facing another issue with downloaded csv showing long number in exponential notation. Is there fix can apply on this file. |
Beta Was this translation helpful? Give feedback.
-
@dosu this is fixing the format in UI, but the downloaded file still showing scientific notation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently we are using 4.0.1 superset version. One of the table chart widget , i m using image tag , to show the status. When we download the table data as excel/cvs, the html tags shown in the exported file. Is there any option to remove that specific column which is having html tags, so that it will not shown up in the exported file.
widget

excel

Beta Was this translation helpful? Give feedback.
All reactions