Skip to content

Commit

Permalink
[DataGridPremium] Namespace Excel export worker (@oliviertassinari) (#…
Browse files Browse the repository at this point in the history
…16539)

Co-authored-by: Olivier Tassinari <[email protected]>
  • Loading branch information
github-actions[bot] and oliviertassinari authored Feb 11, 2025
1 parent b24a9f9 commit 3a6b72d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
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

0 comments on commit 3a6b72d

Please sign in to comment.