Hello,
With a RADGRID built in code behind, I use the ExportToExcel() and ExportToCSV().
It works very well and It's very convenient.
I would like to:
Remove column from my export (e.g. a GridClientSelectColumn which is not relevant)
Modify the data of few columns in my export (e.g. images of a GridImageColumn which must be replace by text)
Add column to my export to put in data whitch are not in the RadGRID
Thanks for your help...
Regards
4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 11 Mar 2011, 09:50 AM
Hello Bernard,
Here is the sample code to achieve your requirement.
ASPX:
C#:
Thanks,
Princy.
Here is the sample code to achieve your requirement.
ASPX:
<Columns> <telerik:GridClientSelectColumn UniqueName="GridClientSelectColumn"> </telerik:GridClientSelectColumn> <telerik:GridImageColumn ImageUrl="../Images/btnGoOver.gif" UniqueName="GridImageColumn"> </telerik:GridImageColumn></Columns>C#:
protected void ExportButton_Click(object sender, EventArgs e) { RadGrid1.ExportSettings.OpenInNewWindow = true; (RadGrid1.MasterTableView.GetColumn("GridClientSelectColumn") as GridClientSelectColumn).Visible = false;//hiding ClientSelectColumn foreach (GridDataItem item in RadGrid1.Items) { TableCell cell = (TableCell)item["GridImageColumn"]; cell.Text = "new text";//replace image with some text } RadGrid1.MasterTableView.ExportToExcel(); }Thanks,
Princy.
0
Bernard
Top achievements
Rank 1
answered on 11 Mar 2011, 03:10 PM
Hi Princy,
It works very well ! Thank you.
What about to "Add column to my export that is not in the RadGRID"
is it possible ?
Regards
It works very well ! Thank you.
What about to "Add column to my export that is not in the RadGRID"
is it possible ?
Regards
0
Princy
Top achievements
Rank 2
answered on 14 Mar 2011, 08:37 AM
Hello Bernard,
One option is you can initially make the column's display as false in RadGrid and when exporting change it display to true like below.
ASPX:
C#:
Thanks,
Princy.
One option is you can initially make the column's display as false in RadGrid and when exporting change it display to true like below.
ASPX:
<Columns> <telerik:GridBoundColumn DataField="EmployeeID" Display="false" UniqueName="EmployeeID"> </telerik:GridBoundColumn> . . . . . . </Columns>C#:
protected void ExportButton_Click(object sender, EventArgs e) { RadGrid1.ExportSettings.OpenInNewWindow = true; . . . . . . (RadGrid1.MasterTableView.GetColumn("EmployeeID") as GridBoundColumn).Display= true; RadGrid1.MasterTableView.ExportToExcel(); }Thanks,
Princy.
0
Bernard
Top achievements
Rank 1
answered on 14 Mar 2011, 02:27 PM
Hi Princy,
Everything is Ok !
Have a good day.
Regard
Bernard
Everything is Ok !
Have a good day.
Regard
Bernard