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

RadGridView Exporting ISSUE

1 Answer 22 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vijay
Top achievements
Rank 1
Vijay asked on 04 Sep 2012, 03:38 PM
Hi Team,

when i try to Export the Grid having 65000 Rows to Excel file i am getting the Error/ IE is Crashing

code i write is as follows

string extension = "xls";
            
 
           string exportType = "Excel";
 
           SaveFileDialog dialog = new SaveFileDialog()
           {
               DefaultExt = extension,
               Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, exportType),
               FilterIndex = 1
           };
 
           if (dialog.ShowDialog() == true)
           {
               using (Stream stream = dialog.OpenFile())
               {
                   MemoryStream ms = new MemoryStream();
                   Pager.PageSize = 0;
                   gridview.Export(ms,
                       new GridViewExportOptions()
                       {
                            
                           Format = ExportFormat.ExcelML,
                           ShowColumnHeaders = true,
                           ShowColumnFooters = false,
                           ShowGroupFooters = false,
                       });
                   ms.Seek(0, SeekOrigin.Begin);
 
                   string header = @"<Row ss:AutoFitHeight='0'><Cell ss:MergeAcross='" + (gridview.Columns.Count - 1).ToString() + "' ><Data ss:Type='String'>" + Heading + "</Data></Cell></Row>";
                   StreamReader sr = new StreamReader(ms);
                   string msStr = sr.ReadToEnd();
                   msStr = msStr.Insert(msStr.IndexOf("<Row>"), header);
                   msStr = msStr.Replace("R1", "R2");
                   stream.Write(Encoding.UTF8.GetBytes(msStr), 0, msStr.Length);
               }
          Pager.PageSize=30;

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 06 Sep 2012, 11:38 AM
Hello,

 May I ask you to share the StackTrace of the Error you got? As I understand you get the exception only when exporting that much records. Is that correct?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Vijay
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or