Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGridPremium] Namespace Excel export worker #16020

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function setupExcelExportWebWorker(
// eslint-disable-next-line no-restricted-globals
addEventListener('message', async (event: MessageEvent<ExcelExportInitEvent>) => {
const {
namespace,
serializedColumns,
serializedRows,
options,
Expand All @@ -23,6 +24,11 @@ export function setupExcelExportWebWorker(
columnGroupPaths,
} = event.data;

// workers share the pub-sub channel namespace. Use this property to filter out messages.
if (namespace !== 'mui-x-data-grid-export') {
return;
}

const { exceljsPostProcess, exceljsPreProcess } = workerOptions;

const excelJS = await getExcelJs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export async function createValueOptionsSheetIfNeeded(
}

export interface ExcelExportInitEvent {
namespace?: string;
serializedColumns: SerializedColumns;
serializedRows: SerializedRow[];
valueOptionsSheetName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export const useGridExcelExport = (
}, {});

const message: ExcelExportInitEvent = {
// workers share the pub-sub channel namespace. Use this property to filter out messages.
namespace: 'mui-x-data-grid-export',
serializedColumns,
serializedRows,
valueOptionsData,
Expand Down