Export to Excel DateFormat

7 posts, 0 answers
  1. GOURVEZ JJ
    GOURVEZ JJ avatar
    55 posts
    Member since:
    Dec 2009

    Posted 16 Mar 2012 Link to this post

    Hi,

    I use radgridview and I want export to Excel.

    All it's ok with your demo, but I want change dateformat.

    Does it possible ?

    And I have an other question, when I export in Excel format, "return at row" fonction is activate. Does it possible do deactivate function ?

    Thanks
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 16 Mar 2012 Link to this post

    Hello,

    Regarding your first question : You can handle the ElementExporting event. Inside the event handler you can manipulate the data to be sent to the export stream including applying different formatting.

    Regarding your second question :
    I am not sure what do you mean by "return at a row " function . Can you please elaborate ?

    All the best,
    Pavel Pavlov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. GOURVEZ JJ
    GOURVEZ JJ avatar
    55 posts
    Member since:
    Dec 2009

    Posted 16 Mar 2012 Link to this post

    Thanks for your answer

    For my second question, is "wrap text" option in Excel.
    I want deactivate it.

    Thanks
  4. GOURVEZ JJ
    GOURVEZ JJ avatar
    55 posts
    Member since:
    Dec 2009

    Posted 19 Mar 2012 Link to this post

    nobody ?
  5. GOURVEZ JJ
    GOURVEZ JJ avatar
    55 posts
    Member since:
    Dec 2009

    Posted 19 Mar 2012 Link to this post

    Hi,

    Do you have an example to export date format ?
    Because I don't find.

    And does it possible to resize width column in ElementExporting event ?

    Thanks

  6. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 21 Mar 2012 Link to this post

    Hello,

    Here is some sample c# code. It illustrates where and how to control the width and format the value:
    public MainPage()
            {
                InitializeComponent();
                 
                this.RadGridView1.ElementExporting += new EventHandler<GridViewElementExportingEventArgs>(RadGridView1_ElementExporting);
            }



    void
    RadGridView1_ElementExporting(object sender, GridViewElementExportingEventArgs e)
            {
                if (e.Element == ExportElement.Cell)
                {
                    var column = e.Context as GridViewDataColumn;
     
                    if (column.UniqueName == "MyDateColumn")
                    {
                        e.Width = 400;
                        e.Value = //format the value of the cell here
                    }
                }
            }


    Greetings,
    Pavel Pavlov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  7. GOURVEZ JJ
    GOURVEZ JJ avatar
    55 posts
    Member since:
    Dec 2009

    Posted 22 Mar 2012 Link to this post

    Hi,

    I have problem with format value.

    This is my code :

    e.Value =

     

    String.Format("{0:dd/MM/yy}", e.Value);

     


    Can you help me ?

    thanks
Back to Top