mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.05k stars 1.25k forks source link

[data grid] Include password protection and set a custom file name for the exported Excel file #12146

Closed lorin-monday closed 6 months ago

lorin-monday commented 6 months ago

The problem in depth

I would like to add password protection to the exported Excel files. Does your package offer any functions, methods, or options for password protection during the export process? If not, I would appreciate any suggestions or guidance on how I can achieve this feature with your package.

Additionally, I would like to set a specific name for the exported files, preferably using the account name. Is it possible to incorporate this functionality using your package? If so, could you please provide some instructions or suggestions on how to implement this?

Your environment

`npx @mui/envinfo` ``` @mui/envinfo@2.0.18 ```

Search keywords: password excelfile Order ID: 59343

michelengelen commented 6 months ago

Hey @lorin-monday ... I am not 100% sure if this is possible. I guess your best shot at this is to use the web worker approach.

@cherniavskii do you know if we can support it like this?

shaharyar-shamshi commented 6 months ago

@lorin-monday @michelengelen If I am not wrong we can use customisation of exceljsPostProcess to generate the password protected excel

code snipper which I think will work is

function exceljsPostProcess({ workbook }: { workbook: ExcelJS.Workbook }) {
  // Get the first worksheet
  const worksheet = workbook.getWorksheet(1);

  // Set password protection for the worksheet
  worksheet.protection = {
    sheet: true,
    password: 'your_password_here' // Replace 'your_password_here' with the desired password
  };
}
michelengelen commented 6 months ago

Seems like the approach from @shaharyar-shamshi might just be what you are looking for @lorin-monday ... could you try that and let us know if that is a sufficient solution for your use case? Thanks! 🙇🏼

github-actions[bot] commented 6 months ago

The issue has been inactive for 7 days and has been automatically closed.