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

RadGridView exporting to excel and pdf

34 Answers 798 Views
GridView
This is a migrated thread and some comments may be shown as answers.
lin
Top achievements
Rank 1
lin asked on 15 May 2009, 05:39 AM
i just wanna to know RadGridView exporting to excel and pdf.


thanks

34 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 15 May 2009, 05:41 AM
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.
0
lin
Top achievements
Rank 1
answered on 15 May 2009, 09:01 AM
 

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
0
Vlad
Telerik team
answered on 15 May 2009, 09:06 AM
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.
0
lin
Top achievements
Rank 1
answered on 15 May 2009, 09:14 AM
u mean IE broswer! or
IE browser Version 6


pls urgent!  thanks
0
Vlad
Telerik team
answered on 15 May 2009, 11:17 AM
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.
0
lin
Top achievements
Rank 1
answered on 18 May 2009, 07:31 AM

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


0
Vlad
Telerik team
answered on 18 May 2009, 07:39 AM
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.
0
lin
Top achievements
Rank 1
answered on 19 May 2009, 06:38 AM
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
0
lin
Top achievements
Rank 1
answered on 20 May 2009, 06:27 AM
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

0
lin
Top achievements
Rank 1
answered on 21 May 2009, 08:12 AM

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

 

 

0
Accepted
Vlad
Telerik team
answered on 21 May 2009, 08:45 AM
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.
0
lin
Top achievements
Rank 1
answered on 21 May 2009, 09:09 AM
hi

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

THANKS
0
Vlad
Telerik team
answered on 21 May 2009, 09:17 AM
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.
0
lin
Top achievements
Rank 1
answered on 21 May 2009, 09:37 AM
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

0
lin
Top achievements
Rank 1
answered on 22 May 2009, 01:44 AM
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


0
Vlad
Telerik team
answered on 22 May 2009, 05:46 AM
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.
0
lin
Top achievements
Rank 1
answered on 22 May 2009, 05:55 AM
hi
i have extension "xls"

thanks
0
satish
Top achievements
Rank 1
answered on 22 May 2009, 06:16 AM
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

0
Vlad
Telerik team
answered on 22 May 2009, 06:37 AM
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.
0
lin
Top achievements
Rank 1
answered on 22 May 2009, 07:02 AM
hi
i got it now!
thanks a lot!


regards
lin

0
lin
Top achievements
Rank 1
answered on 29 May 2009, 08:06 AM
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
0
thdwlgP
Top achievements
Rank 1
answered on 04 Nov 2009, 06:20 PM
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,
0
Vlad
Telerik team
answered on 05 Nov 2009, 06:43 AM
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.
0
Kristof
Top achievements
Rank 1
answered on 23 Mar 2010, 11:18 AM
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
0
Vlad
Telerik team
answered on 23 Mar 2010, 11:33 AM
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.
0
Kristof
Top achievements
Rank 1
answered on 23 Mar 2010, 11:45 AM
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
0
Vlad
Telerik team
answered on 23 Mar 2010, 11:48 AM
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.
0
sachin jagtap
Top achievements
Rank 1
answered on 14 Apr 2010, 12:31 PM
how to export RADGridView to PDF?
0
Vlad
Telerik team
answered on 14 Apr 2010, 12:54 PM
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.
0
Mike Beaton
Top achievements
Rank 1
answered on 09 Jun 2011, 03:59 PM
Hi

Will exporting to PDF ever be supported?

Regards

Mike
0
Vlad
Telerik team
answered on 09 Jun 2011, 04:04 PM
Hi,

 You can check this demo for more info:
http://demos.telerik.com/silverlight/#GridView/PrintAndExportWithRadDocument

Kind 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
0
Mike Beaton
Top achievements
Rank 1
answered on 09 Jun 2011, 04:06 PM
Thanks very much.

Missed that demo.

Regards

Mike
0
Prithvi
Top achievements
Rank 1
answered on 29 Jan 2015, 12:04 PM
I want to export data in rad tree list view to excel, but as it is in tree view, I want to export only the data which is visible, not the node which are collapsed
0
Boris
Telerik team
answered on 03 Feb 2015, 11:48 AM
Hello Prithvi,

A possible way to fulfill your requirement is to follow our SpreadProcessing/RadGridViewIntegration online demo, which provides a way to decide what will be written on each row in the excel or pdf file.

I attached an updated version of the demo that prints only the parent rows in TreeListView.

I hope this help.

Regards,
Boris
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
lin
Top achievements
Rank 1
Answers by
Vlad
Telerik team
lin
Top achievements
Rank 1
satish
Top achievements
Rank 1
thdwlgP
Top achievements
Rank 1
Kristof
Top achievements
Rank 1
sachin jagtap
Top achievements
Rank 1
Mike Beaton
Top achievements
Rank 1
Prithvi
Top achievements
Rank 1
Boris
Telerik team
Share this question
or