Excel Export date fields in UTC timezone after update to Ext.Net 5.2

  1. #1

    Excel Export date fields in UTC timezone after update to Ext.Net 5.2


    we have a GridPanel where we export the grid content to an excel sheet:
                case "xls":
                    this.Response.ContentType = "application/vnd.ms-excel";
                    this.Response.AddHeader("Content-Disposition", "attachment; filename=submittedData.xls");
                    XslCompiledTransform xtExcel = new XslCompiledTransform();
                    xtExcel.Transform(xml, null, Response.OutputStream);
    With Ext.Net Version 3.1, the date fields where exported in local time zone, as they are displayed in the grid.
    After we changed to Ext.Net Version 5.2, the dates are now converted to UTC time zone.

    Is it possible in Ext.Net Version 5.2, that date fields are exported in local time zone, as in Ext.Net Version 3.1?

  2. #2
    Hello Arthur!

    Have you verified it is really Ext.NET's behavior that changed, and not the XLS engine you are using? Can you provide a test case compatible with the way you generate, view, and submit the grid so we can see what's different between the two versions?

    If the date is getting converted until it makes it to code behind you can probably add the date column to this example and we will be able to tell how to avoid or circumvent that behavior:
    - Grid Panel > Selection Models > Submitting Values

    We don't need the xtExcel dependency; if the problem is with Ext.NET we should be able to just Ext.Toast(<dateValueHere>) and tell the difference.

    Looking forward to your follow-up!
  3. #3

    we've tried the Excel export with following examples:



    Here we could see the same behaviour as in our own application:
    With Ext.Net Version 3.1, the date values were exported as they are displayed in the grid.
    With Ext.Net Version 5.2, the date values were exported with conversion to UTC time zone.

    Can you explain why the behaviour is different with these two Ext.Net Versions?

  4. #4
    Hello Arthur!

    Thanks for making it very clear where the problem sits! This is a breaking change introduced by Ext JS. We delayed this breaking change as much as we could in Ext.NET 4. In fact, latest v4 behaves like v3's date-time wise. But unfortunately with Ext.NET 5 release we needed to let it go and adopt Sencha's breaking change.

    To that specific issue you could revert the behavior with the following change to the same example's head HTML block:

    <head runat="server">
        <title>Export Data from GridPanel into XML, Excel or CSV using a full PostBack - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
        <script type="text/javascript">
            Date.prototype.toJSON = function () {
                var ejs_encoded = Ext.JSON.encodeDate(this);
                return ejs_encoded.substring(1, ejs_encoded.length - 1);
        <ext:ResourcePlaceHolder runat="server" />
            var saveData = function () {
                App.Hidden1.setValue(Ext.encode(App.GridPanel1.getRowsValues({selectedOnly : false})));
    This will replace browser's JSON encoder back with Ext JS's which doesn't do this time zone implicit conversion. The ext:ResourcePlaceHolder ensures Ext JS scripts are run after the modification is in effect. And then you'd get the previous versions' behavior.

    More details in issue #1765. Unfortunately we don't have a more definitive fix at hand.

    No matter what solution is devised, the shift must be solved client-side, as the server can't reliably tell which time zone a given client submitting data is in. Well, you can always pass the time zone offset (in minutes) and deduce it from server side too: new Date().getTimezoneOffset(). This should reliably tell how "far" the submitted date and times are from actual values.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Razor pages - EXT.net v7 - Export to excel Issue
    By Geovision in forum 7.x Classic Help
    Replies: 1
    Last Post: Jan 08, 2021, 5:23 PM
  2. [CLOSED] Export data to excel in EXT NET MVC
    By pvera in forum 5.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 13, 2020, 2:39 AM
  3. [CLOSED] close Ext.Net Window after export to excel
    By PriceRightHTML5team in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 04, 2013, 12:06 PM
  4. Replies: 0
    Last Post: Jan 08, 2013, 5:18 AM
  5. Excel export , column header and Null date field
    By springrider in forum 1.x Help
    Replies: 1
    Last Post: Oct 13, 2011, 5:12 PM

Tags for this Thread

Posting Permissions