[CLOSED] GridPanel export to excel/csv - missing date column formatting

  1. #1

    [CLOSED] GridPanel export to excel/csv - missing date column formatting


    I am having the problem with retaining date column format when try to export to excel/csv file from Gridpanel. The problem I'm having is exactly the same as the following thread http://forums.ext.net/showthread.php...umn-formatting , but I didn't see any solution there. Any help is greatly appreciated.

    Last edited by Daniil; May 31, 2011 at 10:46 AM. Reason: [CLOSED]
  2. #2

    I can suggest you to use Convert of RecordField.

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
            if (!X.IsAjaxRequest)
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                    new object[] { "test1", DateTime.Now },
                    new object[] { "test2", DateTime.Now.AddDays(1) },
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <ext:Store runat="server">
                                <ext:RecordField Name="test1" />
                                <ext:RecordField Name="test2" Type="Date">
                                    <Convert Handler="return Ext.util.Format.date(value,'m/d/Y')" />
            <ColumnModel runat="server">
                    <ext:Column Header="Test1" DataIndex="test1" />
                    <ext:Column Header="Test2" DataIndex="test2" />
        <ext:Button runat="server" Text=".getRowsValues()">
                <Click Handler="alert(Ext.encode(GridPanel1.getRowsValues()));" />
  3. #3
    Hi Daniil,

    It didn't work. I can copy and paste my code example, but I think it'd be easier if you use the same example on the Ext.Net demo web page --> https://examples1.ext.net/#/GridPane...Data_PostBack/
    Once you're at the page above (from the link), take a look at the date of the last column called "Last Update". Now, if you click on "To Excel" button, the date of the "Last Updated" would look something like this: 2011-09-01T00:00:00
    If we somehow can retain the same date format in the grid, then that would be the solution I'm looking for. Hope this clear things up a bit. Thank you in advance for your help.

  4. #4
    I still recommend to use Convert:)

    <ext:RecordField Name="lastChange">
        <Convert Handler="var d = Date.parseDate(value, 'n/j h:ia');
                          return Ext.util.Format.date(d, 'Y/m/d h:i:s');" />
    Set up a respective format (ExtJS/PhP format date/time string).
     return Ext.util.Format.date(d, 'Y/m/d h:i:s');
    To get more info about ExtJS/PhP format date/time string, please follow:
  5. #5
    Hi Daniil,

    I appreciate your help, but your suggestion still did not work for me. Have you take a look at the example from the Ext.Net demo page? At this page,
    https://examples1.ext.net/#/GridPane...Data_PostBack/ if you try to export grid records to excel/csv files, the date format would look something like this: 2011-09-01T00:00:00. This would be a problem for our clients. I need a solution where I can export and date format would retain the same date format showing in the grid, i.e. 05/23/2011 (m/d/y)

  6. #6
    Did you apply the Convert I suggested?

    I see something like "2011/05/23 12:00:00" in exported files.

Similar Threads

  1. [CLOSED] Gridpanel export Excel HeaderText
    By CPA1158139 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 10, 2012, 9:36 AM
  2. Data Export Excel Column Names
    By BLOZZY in forum 1.x Help
    Replies: 0
    Last Post: Feb 02, 2012, 2:02 PM
  3. 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
  4. Replies: 2
    Last Post: May 22, 2011, 1:12 AM
  5. How to export GridPanel to the Excel?
    By jachnicky in forum 1.x Help
    Replies: 3
    Last Post: Dec 01, 2008, 4:57 PM

Posting Permissions