I have a radgrid and button (Export To pdf)
The radgrid contains the data
When I click the Export to pdf button
The datas are shown in the pdf
Before that a screen appears for open or save
if open i given it opens the pdf
If save is given then the path if asked, and then it is saved
IS THERE ANY OPTION TO AUTOMATICALLY SAVE THE PDF
-Anto
20 Answers, 1 is accepted
The following blog post will surely be helpful:
How To: Export grid to PDF file and show the result using the window
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
What do I need is
The pdf should not be shown
When Export to pdf is clicked
The file must be automatically saved in a location specified in coding.
Is there any option for this
-Anto
Have a look at the following code-snippet:
<asp:Button ID="Button1" runat="server" Text="Save on server" /> |
<telerik:RadGrid ID="RadGrid1" runat="server" Skin="Vista" Width="500px"> |
<ExportSettings ExportOnlyData="true" /> |
</telerik:RadGrid> |
Public Partial Class _Default |
Inherits System.Web.UI.Page |
Private url As String, path As String = "" |
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load |
url = [String].Format("~/{0}.pdf", RadGrid1.ExportSettings.FileName) |
path = Server.MapPath(url) |
End Sub |
Protected Sub RadGrid1_NeedDataSource(source As Object, e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource |
Dim table As New DataTable() |
table.Columns.Add("ID", GetType(Integer)) |
table.Columns.Add("Name", GetType(String)) |
table.Rows.Add(1, "Michael") |
table.Rows.Add(2, "George") |
RadGrid1.DataSource = table |
End Sub |
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click |
RadGrid1.MasterTableView.ExportToPdf() |
End Sub |
Protected Sub RadGrid1_GridExporting(source As Object, e As GridExportingArgs) Handles RadGrid1.GridExporting |
If File.Exists(path) Then |
'DELETE THE FILE IF ALREADY EXISTS |
File.Delete(path) |
End If |
Using fs As FileStream = File.Create(path) |
Dim info As [Byte]() = System.Text.Encoding.[Default].GetBytes(e.ExportOutput) |
'SAVE IT ON THE SERVER |
fs.Write(info, 0, info.Length) |
End Using |
Response.Redirect("~/Default.aspx") |
End Sub |
End Class |
Regards,
Daniel
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
I am C# guy. Please could u send it in C#
-Anto
You can find the C# version of this code in the link, I provided in my first post.
Alternatively you can use our online converter:
Code Converter
Regards,
Daniel
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Thank you
I have solved it
-Anto
If i Comment out the code Response.Redirect("~/Default.aspx") the excel file Opens in same window.
Please Suugest as i want to fals an information to the user after export to excel and not redirect.
Regards,
Ashwin
If i Comment out the code Response.Redirect("~/Default.aspx") the excel file Opens in same window.
Please Suugest as i want to fals an information to the user after export to excel and not redirect.
Regards,
Ashwin
If i Comment out the code Response.Redirect("~/Default.aspx") the excel file Opens in same window.
Please Suugest as i want to fals an information to the user after export to excel and not redirect.
Regards,
Ashwin
As you properly noticed, if you don't redirect the response, it will reach the client's browser and will result in open/save dialog. The other option is to call Response.End, but this will show an empty page, so I doubt it will do the trick for you.
Regards,
Daniel
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.
i want to export radgrid in hierarchy
and i dont want to use onneeddatasource
i bind datasource to radgrid in buttonclick event
code:
gridname.ExportSettings.FileName = "filename";
gridname.ExportSettings.ExportOnlyData = true;
gridname.ExportSettings.IgnorePaging = true;
gridname.ExportSettings.OpenInNewWindow = true;
gridname.MasterTableView.UseAllDataFields = true;
gridname.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML;
gridname.MasterTableView.HierarchyDefaultExpanded = true;
gridname.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;
gridname.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
gridname.MasterTableView.DetailTables[0].HierarchyLoadMode = GridChildLoadMode.Client;
gridname.MasterTableView.ExportToExcel();
when i dont use onneeddatasource for grid it give me object reference is not set error
Note that we strongly recommend to use advanced data-binding through NeedDataSource event when perform complex operations such hierarchy and export. Even if you manage to export the grid I could not be sure whether the export output will display all the information of the grid and whether the correct format will be applied.
Regards,
Kostadin
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.
Hello Telerik team,
I have one excel template file and I want to copy some sheets of that file and convert to PDF file. I am using .Net 3.5 version. Please suggest me step by step way if its possible form telerik. or also suggest me if possible from any free tool. I don't want to purchase any other tool as I am using telerik for long time.
waiting for your response.
Regards
Pankaj
Please examine the following live example which demonstrates how to convert a Excel document to PDF.
Regards,
Kostadin
Telerik
Hello,
I am not getting below DLL for .net 3.5 version. Can you help me where I will get it.
Imports Telerik.Windows.Documents.Spreadsheet.FormatProviders
Imports Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx
Imports Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf
Imports Telerik.Windows.Documents.Spreadsheet.FormatProviders.TextBased.Csv
Imports Telerik.Windows.Documents.Spreadsheet.FormatProviders.TextBased.Txt
Imports Telerik.Windows.Documents.Spreadsheet.Model
I am afraid DPL is not supported for .NET 3.5. You can find more information in the following help article.
Regards,
Kostadin
Telerik
but the data at the radGrid is empty - the parameters at the page not saved. It's a problem...
How can I come back to the page, but the parameters and the data should remain?
or How can I export to excel and prevent the following message to appear without redirect to the page?
If you'd like to save a file on the server using the built-in export, then you should use that approach. Alternatively you can generate the output file on your own by traversing the control and building the corresponding structure in code-behind.
Regards,
Daniel
Telerik by Progress
As I understand from you - this is a limitation of Telerik "Save exporting file" mechanism, should It be fixed in next version? (this is very important)
Besides,
I am looking for an event that happened AFTER the Xslx file exported (in order to display alert - the RadWindowManager does not show alert if I write it in the GridExporting event).
I would like to show a message when the file exporting completed.
Can you assist please?
Straight onto your questions.
As I understand from you - this is a limitation of Telerik "Save exporting file" mechanism, should It be fixed in next version? (this is very important)
I'm afraid this can't be fixed. The built-in export functionality is designed to stream the output to the response. There are multiple changes made during the ASP.NET lifecycle which are irreversible.
I am looking for an event that happened AFTER the Xslx file exported (in order to display alert - the RadWindowManager does not show alert if I write it in the GridExporting event).
There is no such event. If you want to be notified when the file is ready then you may use a cookie as shown here.
Show loading panel when exporting RadGrid
I'd like to note that none of these are supported out of the box.
Regards,
Daniel
Telerik by Progress