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

[Solved] Problem in export to excel

5 Answers 173 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
suresh
Top achievements
Rank 1
suresh asked on 16 Oct 2009, 05:08 AM
Hi,
     I am using radgrid view and implementing export to excel functionality.It is working fine for small data but is showing error when i am trying to export large data.Is there a solution for this problem.

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Oct 2009, 05:58 AM
Hi suresh,

Can you provide a bit more info about the grid version, how many records you are trying to export and what says the error?

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
suresh
Top achievements
Rank 1
answered on 19 Oct 2009, 07:01 AM
Hi,

     There are around 2000 records and error is Dialogs must be user initiated ans it is occurring at if(dialog.showdialog().value) condition.


Previously i used to get this error if i am having a break point in the code.But when it comes to large data i am getting this error even without any break point.
0
Vlad
Telerik team
answered on 20 Oct 2009, 12:16 PM
Hi,

I've tried this and indeed you can get such exception if you try to execute some slow operation before ShowDialog() method however you can easily fix this if you call desired grid method after this. Here is an example:

       private void Button_Click(object sender, RoutedEventArgs e)
        {
            string extension = "xls";
            SaveFileDialog dialog = new SaveFileDialog()
            {
                DefaultExt = extension,
                Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel"),
                FilterIndex = 1
            };

            if (dialog.ShowDialog() == true)
            {
                using (Stream stream = dialog.OpenFile())
                {
                    using (StreamWriter sw = new StreamWriter(stream, Encoding.UTF8))
                    {
                        sw.Write(RadGridView1.ToHtml());
                    }
                    stream.Close();
                }
            }
        }

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
suresh
Top achievements
Rank 1
answered on 26 Oct 2009, 05:49 AM
Hi,
      I have tried with the code.But i am still getting the error .
0
Vlad
Telerik team
answered on 26 Oct 2009, 07:35 AM
Hi,

I've attached small example demonstrating suggested approach. No errors on my end.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
suresh
Top achievements
Rank 1
Answers by
Vlad
Telerik team
suresh
Top achievements
Rank 1
Share this question
or