This is a migrated thread and some comments may be shown as answers.

Add head title on Excel GridView Export

6 Answers 146 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sami
Top achievements
Rank 2
Iron
Iron
Iron
Sami asked on 25 Jul 2011, 11:29 PM
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...

6 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 26 Jul 2011, 08:41 AM
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!

0
Sami
Top achievements
Rank 2
Iron
Iron
Iron
answered on 26 Jul 2011, 04:22 PM
Hi, I have read the answer in the support ticket, really good answer, that's what I wanted... 

Thank you very much
Sami
0
Richard
Top achievements
Rank 1
answered on 10 Aug 2011, 04:15 PM
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!

0
Ivan Ivanov
Telerik team
answered on 10 Aug 2011, 04:24 PM
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 >>
0
Richard
Top achievements
Rank 1
answered on 10 Aug 2011, 05:09 PM
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.
0
Leandro
Top achievements
Rank 1
answered on 07 Dec 2011, 12:57 PM
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
Tags
GridView
Asked by
Sami
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Ivan Ivanov
Telerik team
Sami
Top achievements
Rank 2
Iron
Iron
Iron
Richard
Top achievements
Rank 1
Leandro
Top achievements
Rank 1
Share this question
or