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

[data grid] Export to Excel default Date format is "dd.mm.yyyy" and it's too difficult to override for the entire system #13118

Closed
nycgavin opened this issue May 13, 2024 · 2 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: extend Logic customizability feature: Export status: waiting for author Issue with insufficient information support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@nycgavin
Copy link

nycgavin commented May 13, 2024

Summary

The current date format for export to excel feature on Data Grid Premium is dd.mm.yyyy, while this is suitable for Europe countries. In the United States, the default format should be mm/dd/yyyy, and currently the only way to overwrite the default format is at the column style level.

<GridToolbarExport
  excelOptions={{
    columnsStyles: {
      // replace the dd.mm.yyyy default date format
      recruitmentDay: { numFmt: 'dd/mm/yyyy' },
      // set this column in green
      incomes: { font: { argb: 'FF00FF00' } },
    },
  }}
/>

this is too tedious because I will need to define a column style for all date columns in all data grid.

I wish to overwrite the default date and datetime style at the datagrid level, not at the column level.

Examples

No response

Motivation

No response

Search keywords: excel export datagrid
Order ID: 51732

@nycgavin nycgavin added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 13, 2024
@michelengelen
Copy link
Member

michelengelen commented May 14, 2024

There is an option to pas this at the DataGrid level.
You can pass in the excelOptions into the slotProps like this:

const excelOptions = {
  columnsStyles: {
    // replace the dd.mm.yyyy default date format
    recruitmentDay: { numFmt: 'dd/mm/yyyy' },
    // set this column in green
    incomes: { font: { argb: 'FF00FF00' } },
  },
};

export default function ExcelCustomExport() {
  return (
    <DataGridPremium
      rows={rows}
      columns={columns}
      slots={{ toolbar: GridToolbar }}
      slotProps={{ toolbar: { excelOptions } }}
    />
  );
}

Is this a suitable solution for your use-case?

@michelengelen michelengelen added component: data grid This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information feature: Export customization: extend Logic customizability support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 14, 2024
@michelengelen michelengelen changed the title MUI X data grid Export to Excel default Date format is "dd.mm.yyyy" and it's too difficult to override for the entire system [data grid] Export to Excel default Date format is "dd.mm.yyyy" and it's too difficult to override for the entire system May 14, 2024
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: extend Logic customizability feature: Export status: waiting for author Issue with insufficient information support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

2 participants