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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid - Excel Export

Thread ID:

Created:

Updated:

Platform:

Replies:

151236 Feb 4,2020 07:59 PM UTC Feb 12,2020 11:22 AM UTC JavaScript - EJ 2 3
loading
Tags: Grid
Matias Puzanowski
Asked On February 4, 2020 07:59 PM UTC

Hello Syncfusion team,

When exporting to Excel, is it possible to set a cell on a specific type? Previously we were using some controls from another company and it was possible.

We have some columns with time (HH:mm) that were exported on 'Custom' format and now they are exported as 'Text' and it was very useful for our customers to export to Excel and directly sum this columns. 

Thanks in advance.

Balaji Sekar [Syncfusion]
Replied On February 5, 2020 09:11 AM UTC

Hi Matias, 
 
Greetings from Syncfusion forum. 
 
We have validated and achieved your requirement using excelQueryCellInfo and getDateFormat method based on our assumptions. 
 
Query: it possible to set a cell on a specific type?  
 
Yes, wou can set column in specific type using  ‘type’ property in column level. 
 
 
We have applied the “Applied” Column as in HH: mm Custom format and are shown in that format. The getDateFormat method that returns a function that formats a date object based on the specified DateFormatOptions. Using this format in excelQueryCellInfo, we can export the value as in text with corresponding format options. Using this text value we can perform whatever we want. 
 
Reference links. 
 
 
 
Please refer to the below code and sample link. 
 
var intl = new ej.base.Internationalization() 
var grid = new ej.grids.Grid({ 
dataSource: data, 
  allowExcelExport: true, 
 .. . . . 
  columns: [ 
. . . . 
    { 
      field: "Applied", 
      headerText: "Order Date", 
      width: 130, 
      format: {type:'date', format:'HH:mm'}, 
      textAlign: "Right" 
    } 
  ], 
  excelQueryCellInfo: function(e) {debugger; 
  if(e.column.field === 'Applied'){ 
    var format = e.column.format; 
    var intl = new ej.base.Internationalization(); 
    var dFormatter = intl.getDateFormat(format); 
    e.value = dFormatter(e.value); 
    console.log(e.value); // returns text value  
  } 
  } 
}); 
grid.appendTo("#Grid"); 

 
 
Still, facing the issue please share the below details. 
 
  1. Structural view of your dataSource
  2. Pictorial representation of your requirement.
  3. Explain your requirement briefly.
 
Please get back to us, if you need any further assistance. 
 
Regards, 
Balaji Sekar. 


Matias Puzanowski
Replied On February 5, 2020 12:48 PM UTC

Hello!

Thanks a lot for your response.

I'm providing an example from an Excel export of our previous grid control (Selecting 'HH:mm' cells, you are able to SUM)


And we cannot achieve this with the solution you provided:


Thiyagu Subramani [Syncfusion]
Replied On February 12, 2020 11:22 AM UTC

Hi Matias ,  

Thanks for your update. 

We have checked issue with your reported information. In previous update value for the column “OrderDate” is passed as string(text) values instead of date time object as per your requirement. Because of this, Excel export serializes the values as string. So, the SUM action in Excel is not performed. Its default behavior of excel . So, we suggest you to set the cell value as Date time instance to make the Excel perform SUM action. In this below sample, once we reach the edit state to the corresponding exported text value cell , its act as the  default excel cell format like below image. 

 

 

   
Please let us know if you have any queries.  

Regards,  
Thiyagu S.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon