We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Date format

Version @syncfusion/ej2-vue-spreadsheet 19.1.59

When loaded file, date format is 'mm/dd/yyyy'.

How change 'Short date' format on 'dd.mm.yyyy' 


Thank you.


3 Replies

SP Sangeetha Priya Murugan Syncfusion Team February 10, 2023 08:56 AM UTC

Hi,


Your requirement can be achieved by using the custom number formatting option in the UI level through the toolbar button. To apply this format programmatically, you can use the numberFormat method. Please find the sample link below.


Sample Link: https://stackblitz.com/edit/lb7nsg?file=index.ts


Demo Link: https://ej2.syncfusion.com/vue/demos/#/bootstrap5/spreadsheet/number-formatting.html


Documentation Link: https://ej2.syncfusion.com/vue/documentation/spreadsheet/formatting/#number-formatting






?? ????????? ???????? February 10, 2023 09:48 AM UTC

We opened file by URL, and we don`t know where date cells been.

How overide ShortDate globaly.

Thanks.



SP Sangeetha Priya Murugan Syncfusion Team February 13, 2023 12:43 PM UTC

Hi,


Your requirement to apply the custom number formats for imported excel file can be achieved by using the actionComplete and openComplete event as shown below.


Code Block:


 

 

 openComplete: (): void => {

    applyFormat();

  },

  actionComplete: (args): void => {

    if (args.action == 'gotoSheet') applyFormat();// apply number format for multiple sheets while tab switching.

  },

 

function applyFormat() {

  let sheet = spreadsheet.getActiveSheet();

  let range = sheet.usedRange;

  for (var i = 0; i <= range.rowIndex; i++) {

    for (var j = 0; j <= range.colIndex; j++) {

      let cell = getCell(i, j, sheet);

      if (cell && cell.format === 'mm-dd-yyyy') {

        let address = getCellAddress(i, j);

        spreadsheet.numberFormat('dd.mm.yyyy', address); // apply number format

      }

    }

  }

}

 


Sample Link: https://stackblitz.com/edit/lb7nsg-dm8xlp?file=index.ts


Loader.
Up arrow icon