RadGridView Exporting ISSUE

2 posts, 0 answers
  1. Vijay
    Vijay avatar
    13 posts
    Member since:
    May 2012

    Posted 04 Sep 2012 Link to this post

    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;
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 06 Sep 2012 Link to this post

    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.

Back to Top