-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Fix Excel export Web Worker demo not working in dev mode #16517
Merged
cherniavskii
merged 8 commits into
mui:master
from
cherniavskii:fix-excel-webworker-in-dev-mode
Feb 11, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3e51eb1
Move setupExcelExportWebWorker to a separate file
cherniavskii e9564ab
remove unused file
cherniavskii 32fb620
add subpath export for setupExcelExportWebWorker
cherniavskii 7bd9353
use subpath export
cherniavskii 7ce3ea3
fix ts error
cherniavskii 71e026a
bump to 50k rows
cherniavskii c2415ee
Merge branch 'master' into fix-excel-webworker-in-dev-mode
cherniavskii e1217c9
Merge branch 'master' into fix-excel-webworker-in-dev-mode
cherniavskii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Used in ExcelExportWithWebWorker demo | ||
import { setupExcelExportWebWorker } from '@mui/x-data-grid-premium'; | ||
import { setupExcelExportWebWorker } from '@mui/x-data-grid-premium/setupExcelExportWebWorker'; | ||
|
||
setupExcelExportWebWorker(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Used in ExcelExportWithWebWorker demo | ||
import { setupExcelExportWebWorker } from '@mui/x-data-grid-premium'; | ||
import { setupExcelExportWebWorker } from '@mui/x-data-grid-premium/setupExcelExportWebWorker'; | ||
|
||
setupExcelExportWebWorker(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/x-data-grid-premium/src/hooks/features/export/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './gridExcelExportInterface'; | ||
|
||
export { setupExcelExportWebWorker } from './serializer/excelSerializer'; | ||
export { setupExcelExportWebWorker } from './serializer/setupExcelExportWebWorker'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ges/x-data-grid-premium/src/hooks/features/export/serializer/setupExcelExportWebWorker.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import type * as Excel from 'exceljs'; | ||
import type { GridExcelExportOptions } from '../gridExcelExportInterface'; | ||
import { | ||
addColumnGroupingHeaders, | ||
addSerializedRowToWorksheet, | ||
createValueOptionsSheetIfNeeded, | ||
ExcelExportInitEvent, | ||
getExcelJs, | ||
} from './utils'; | ||
|
||
export function setupExcelExportWebWorker( | ||
workerOptions: Pick<GridExcelExportOptions, 'exceljsPostProcess' | 'exceljsPreProcess'> = {}, | ||
) { | ||
// eslint-disable-next-line no-restricted-globals | ||
addEventListener('message', async (event: MessageEvent<ExcelExportInitEvent>) => { | ||
const { | ||
serializedColumns, | ||
serializedRows, | ||
options, | ||
valueOptionsSheetName, | ||
valueOptionsData, | ||
columnGroupDetails, | ||
columnGroupPaths, | ||
} = event.data; | ||
|
||
const { exceljsPostProcess, exceljsPreProcess } = workerOptions; | ||
|
||
const excelJS = await getExcelJs(); | ||
const workbook: Excel.Workbook = new excelJS.Workbook(); | ||
const worksheet = workbook.addWorksheet('Sheet1'); | ||
|
||
worksheet.columns = serializedColumns; | ||
|
||
if (exceljsPreProcess) { | ||
await exceljsPreProcess({ workbook, worksheet }); | ||
} | ||
|
||
if (options.includeColumnGroupsHeaders) { | ||
addColumnGroupingHeaders(worksheet, serializedColumns, columnGroupPaths, columnGroupDetails); | ||
} | ||
|
||
const includeHeaders = options.includeHeaders ?? true; | ||
if (includeHeaders) { | ||
worksheet.addRow(serializedColumns.map((column) => column.headerText)); | ||
} | ||
|
||
createValueOptionsSheetIfNeeded(valueOptionsData, valueOptionsSheetName, workbook); | ||
|
||
serializedRows.forEach((serializedRow) => { | ||
addSerializedRowToWorksheet(serializedRow, worksheet); | ||
}); | ||
|
||
if (exceljsPostProcess) { | ||
await exceljsPostProcess({ workbook, worksheet }); | ||
} | ||
|
||
postMessage(await workbook.xlsx.writeBuffer()); | ||
}); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this file was ever used