RadGridView exporting to excel and pdf

35 posts, 1 answers
  1. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 15 May 2009 Link to this post

    i just wanna to know RadGridView exporting to excel and pdf.


    thanks
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 15 May 2009 Link to this post

    Hello lin,

    Please check this demo for more info about available grid export options:
    http://demos.telerik.com/silverlight/#GridView/Exporting

    Kind regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 15 May 2009 Link to this post

     

    Server Error in '/' Application.

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /Export.xls


    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

    can u help me?

    thanks
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 15 May 2009 Link to this post

    Hi lin,

    I just tried our demo however the exporting worked fine - screenshot attached.

    Can you provide more info about your browser?

    Sincerely yours,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 15 May 2009 Link to this post

    u mean IE broswer! or
    IE browser Version 6


    pls urgent!  thanks
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 15 May 2009 Link to this post

    Hi lin,

    I tried our demo in IE7, FireFox 3 and Chrome and again everything worked fine - unfortunately I'm not sure why you have such problems at your end.

    You can try our demos locally.

    All the best,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 18 May 2009 Link to this post

    hi

    i test alreday with my proj. but still got error! because my proj http is http://localhost/mytestingpage.aspx
    following error.....


    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /Export.xls

     
    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

    can u help me?

    thanks


  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 18 May 2009 Link to this post

    Hello lin,

    Can you send us (via support ticket ticket) the project where this can be reproduced?

    Sincerely yours,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 19 May 2009 Link to this post

    hi


    acutally code is working! but my app http is wrong way!
    my app http is address is http://localhost/myappname.aspx
    and then click the Export Button! after that http address is http://localhost/Export.xls

    show the following error message!

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /Export.xls


    still trying
    thanks
  11. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 20 May 2009 Link to this post

    hi
    i think i need to change
    that one!

    Uri

     

    uri = new Uri(HtmlPage.Document.DocumentUri, String.Format("ExportHandler.aspx?type={0}", extension));

     


    ExportHandler.aspx  to myapptestingpage.aspx

    but! also can not!


    let me know

  12. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 21 May 2009 Link to this post

    hi


    my code here!

    Uri
    uri = new Uri(HtmlPage.Document.DocumentUri, String.Format("SanofiApplicationTestPage.aspx?type={0}", extension));

     

     

     

     

    WebClient client = new WebClient();  

    client.UploadStringCompleted +=

    new UploadStringCompletedEventHandler(client_UploadStringCompleted);

     

    client.UploadStringAsync(uri,content);


      void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
            {
                HtmlPage.Window.Navigate(new Uri(HtmlPage.Document.DocumentUri, String.Format("Export.{0}", extension)), "_blank");
            }



    i use  mytestpage name aspx instead of ExportHandler.aspx
    can i use?
    i think so!
    Requested URL: /Export.xls

    help me urgent!pls

    thanks

     

     

  13. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 21 May 2009 Link to this post

    Hello lin,

    Indeed you can use your own page to save the export to file.

    Greetings,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  14. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 21 May 2009 Link to this post

    hi

    so! u mean! export.xls file is autocreat right!

    THANKS
  15. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 21 May 2009 Link to this post

    Hi lin,

    Here is the relevant code for export file saving:

            protected void Page_Load(object sender, EventArgs e)
            {
                string path = Server.MapPath(String.Format("~/Export.{0}", Request.QueryString["type"]));

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                using (FileStream fs = File.Create(path))
                {
                    using (StreamReader sr = new StreamReader(Request.InputStream))
                    {
                        Byte[] info = System.Text.Encoding.Default.GetBytes(sr.ReadToEnd());
                        fs.Write(info, 0, info.Length);
                    }
                }
            }

    You need to add this in your page.

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  16. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 21 May 2009 Link to this post

    Line 9:      protected void Page_Load(object sender, EventArgs e)
    Line 10:     {
    Line 11: string path = Server.MapPath(String.Format("~/Export.{0}", Request.QueryString["type"]));Line 12: 
    Line 13:         if (System.IO.File.Exists(path))




    help me pls!
    thanks

  17. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 21 May 2009 Link to this post

    hi

    actually  following code is inside mysilverlight control xaml cs file 

     


    Uri
    uri = new Uri(HtmlPage.Document.DocumentUri, String.Format("SanofiApplicationTestPage.aspx?type={0}", extension));

     

     

    WebClient client = new WebClient();

     

     

    //client.Headers[HttpRequestHeader.ContentType] = "application/vnd.ms-excel";

     

    client.UploadStringCompleted +=

    new UploadStringCompletedEventHandler(client_UploadStringCompleted);

     

    client.UploadStringAsync(uri,content);

     

     

    }

     

    void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)

     

    {

     

    HtmlPage.Window.Navigate(new Uri(HtmlPage.Document.DocumentUri, String.Format("Export.{0}", extension)), "_blank");

     

    }

    this following code is inside myapptname.aspx page!
     protected void Page_Load(object sender, EventArgs e)
            {
                string path = Server.MapPath(String.Format("~/Export.{0}", Request.QueryString["type"]));

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                using (FileStream fs = File.Create(path))
                {
                    using (StreamReader sr = new StreamReader(Request.InputStream))
                    {
                        Byte[] info = System.Text.Encoding.Default.GetBytes(sr.ReadToEnd());
                        fs.Write(info, 0, info.Length);
                    }
                }
            }

    but! show the error message "Failed to map the path '/Export'."
    so! how can i do that!

    thanks


  18. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 22 May 2009 Link to this post

    Hello lin,

    Do you have any value in "extension" field?

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  19. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 22 May 2009 Link to this post

    hi
    i have extension "xls"

    thanks
  20. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 22 May 2009 Link to this post

    Hi Lin,

      I am also facing the same problem. Can you please help me in exporting the grid.

    Here is my code:

    Uri

     

    uri = new Uri(HtmlPage.Document.DocumentUri, String.Format("ExportHandler.aspx?type={0}", extension));

     

     

    WebClient client = new WebClient();

     

    client.UploadStringCompleted +=

    new UploadStringCompletedEventHandler(client_UploadStringCompleted);

     

    client.UploadStringAsync(uri, content);

     

     

    void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)

     

    {

     

    HtmlPage.Window.Navigate(new Uri(HtmlPage.Document.DocumentUri, String.Format("Export.{0}", extension)), "_blank");

     

    }




    Ahead of you for your response.

    Regards
    Satish

  21. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 22 May 2009 Link to this post

    Hello,

    I've attached an example project demonstrating how to export RadGridView to Excel.

    Kind regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  22. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 22 May 2009 Link to this post

    hi
    i got it now!
    thanks a lot!


    regards
    lin

  23. lin
    lin avatar
    16 posts
    Member since:
    May 2009

    Posted 29 May 2009 Link to this post

    hi

    string

     

    path = Server.MapPath(String.Format("~/subfloder/Export.{0}", Request.QueryString["type"]));

    and then myapp deployed  to Server!

    but! Error!

     


    System.Web.HttpException: Failed to map the path '/appfloder/subfloder/Export.'.


    help me pls!


    thanks
    rgds
    lin
  24. thdwlgP
    thdwlgP avatar
    34 posts
    Member since:
    Mar 2009

    Posted 04 Nov 2009 Link to this post

    Vlad,
    Once I save my .xls file and i try to open it shows a warning message.
    "The file you are trying to open, 'name.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before oepning the file. Do you want to open the file now?"

    I press yes and it looks fine but why am I getting that warning message?
    My code looks like...
            private void btnExportToExcel_Click(object sender, RoutedEventArgs e)  
            {  
                Uri uri = new Uri(HtmlPage.Document.DocumentUri, string.Format("ExportReport.aspx?Name={0}", uxSectionTitle.Text));  
     
                WebClient client = new WebClient();  
                client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted);  
                client.UploadStringAsync(uri, uxKPIDetails.ToHtml(true));  
            }  
     
            void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)  
            {  
                Uri uri = new Uri(HtmlPage.Document.DocumentUri, string.Format("{0}.xls", uxSectionTitle.Text));  
                HtmlPage.Window.Navigate(uri);  
            } 

    And in my ExportReport.aspx
    protected void Page_Load(object sender, EventArgs e)  
            {  
                if (Request.QueryString["Name"] != null)  
                {  
                    string fileName = Request.QueryString["Name"].ToString();  
                    string path = Server.MapPath(fileName + ".xls");  
     
                    if (File.Exists(path))  
                    {  
                        File.Delete(path);  
                    }  
     
                    using (StreamReader sr = new StreamReader(Request.InputStream, Encoding.UTF8))  
                    {  
                        StreamWriter sw = new StreamWriter(path);  
                        sw.Write(sr.ReadToEnd());  
                        sw.Close();  
                        sr.Close();  
                    }                  
                }  
            } 

    Thanks,
  25. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 05 Nov 2009 Link to this post

    Hello thdwlgP,

    You will get such message from Excel 2007 since the format of the file is not XLSX.

    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.
  26. Kristof
    Kristof avatar
    10 posts
    Member since:
    Mar 2010

    Posted 23 Mar 2010 Link to this post

    Hello Vlad,

    When I run the application I get an InvalidOperationException: Access is denied...
    Do you know what the problem is?

    StackTrace:
       at System.Windows.Browser.ScriptObject.Invoke(String name, Object[] args)
       at System.Windows.Browser.HtmlWindow.Navigate(Uri navigateToUri, String target, String targetFeatures)
       at System.Windows.Browser.HtmlWindow.Navigate(Uri navigateToUri, String target)
       at SilverlightApplication3.Page.client_UploadStringCompleted(Object sender, UploadStringCompletedEventArgs e)
       at System.Net.WebClient.OnUploadStringCompleted(UploadStringCompletedEventArgs e)
       at System.Net.WebClient.UploadStringOperationCompleted(Object arg)

    Thanks and regards,
    Kristof
  27. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 23 Mar 2010 Link to this post

    Hello Kristof,

    I'm not sure why you get this however since Silverlight 3 you can save directly the grid export similar to our demo - no need to upload to the server.

    Regards,
    Vlad
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  28. Kristof
    Kristof avatar
    10 posts
    Member since:
    Mar 2010

    Posted 23 Mar 2010 Link to this post

    Hello Vlad,

    In the demo you use an Export method

    If dialog.ShowDialog() = True Then 
                Using stream As Stream = dialog.OpenFile()  
                    grdMCPOverview.Export(stream, New GridViewExportOptions())  
                End Using  
            End If 

    But I can't use that method because Export is not a member of Telerik.Windows.Controls.RadGridView.
    I use the version 2009.3.1103.1030 of the dll's.

    Is there an other way to do it...

    Thanks and regards,
    Kristof
  29. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 23 Mar 2010 Link to this post

    Hi Kristof,

    Generally Export() method  is added for Q1 2010 however with Q3 2009 you can use ToXXX extension methods to achieve your goal.

    Greetings,
    Vlad
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  30. sachin jagtap
    sachin jagtap avatar
    15 posts
    Member since:
    Jul 2009

    Posted 14 Apr 2010 Link to this post

    how to export RADGridView to PDF?
  31. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 14 Apr 2010 Link to this post

    Hi,

    Currently exporting to PDF is not supported.

    Greetings,
    Vlad
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
DevCraft banner