Add head title on Excel GridView Export

7 posts, 1 answers
  1. Sami
    Sami avatar
    12 posts
    Member since:
    Feb 2011

    Posted 25 Jul 2011 Link to this post

    Hi, I have an application which uses GridView Exporting to excel. It works fine, and I want to add a Head Title on the Excel File, but when I put The Head Title, the Unicode Encoding or UTF8 Encoding doesn't work, this is my code:

    if (dialog.ShowDialog() == true)
                {
                    using (Stream stream = dialog.OpenFile())
                    {
                        GridViewExportOptions exportOptions = new GridViewExportOptions();
                        exportOptions.Format = format;
                        exportOptions.ShowColumnFooters = false;
                        exportOptions.ShowColumnHeaders = true;
                        exportOptions.ShowGroupFooters = false;
                        exportOptions.Encoding = Encoding.UTF8;
     
     
                        
                        String unicodeString = "Título de la Aplicación\n";
                        unicodeString = unicodeString + "Sub Título de la Aplicación";
                        Encoding unicode = Encoding.Unicode;
                        byte[] unicodeBytes = unicode.GetBytes(unicodeString);
                        stream.Write(unicodeBytes, 0, unicodeBytes.Length);
                        gridExport.Export(stream, exportOptions);
     
                    }
                }


    Could you help me please...

    Thanks in advanced...
  2. Answer
    Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1216 posts

    Posted 26 Jul 2011 Link to this post

    Hello Sami,

    I have just posted an answer in the other thread you have opened. In order to achieve a fruitful and consistent dialogue, I would kindly ask you to carry out any further communication there.

    Best wishes,
    Ivan Ivanov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Sami
    Sami avatar
    12 posts
    Member since:
    Feb 2011

    Posted 26 Jul 2011 Link to this post

    Hi, I have read the answer in the support ticket, really good answer, that's what I wanted... 

    Thank you very much
    Sami
  4. Richard
    Richard avatar
    11 posts
    Member since:
    Aug 2010

    Posted 10 Aug 2011 Link to this post

    I'd love to see the response that you gave to SAMI, but I can't find it.  It sounds like this is the answer to my questions too, but what's the link?

    Thanks!

  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1216 posts

    Posted 10 Aug 2011 Link to this post

    Hello Richard,

    I am attaching the example project.

    Kind regards,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  6. Richard
    Richard avatar
    11 posts
    Member since:
    Aug 2010

    Posted 10 Aug 2011 Link to this post

    I needed to add some info above the header line, so I used this and it created a new line between the title and the headers

    byte[] title = Encoding.UTF8.GetBytes("Exporting EXCEL!" + System.Environment.NewLine);

    Thanks for your quick reply with the code example.
  7. Leandro
    Leandro avatar
    7 posts
    Member since:
    Apr 2011

    Posted 07 Dec 2011 Link to this post

    I am using your example but when I use:
    exportOptions.Encoding = System.Text.Encoding.Unicode;

    it doesn't work!

    how can I solve this problem?

    Thanks,
    Leandro Christen
Back to Top