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

[Solved] Export Grid data In Excel

3 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vij
Top achievements
Rank 1
Vij asked on 09 Apr 2013, 08:52 PM
Dear Experts,
I am newbie in using telerik controls.
I have 25 columns in my select command, in which I want to show only 5 columns to users on UI, but when user export that data in excel file then all 25 columns value should exported in  excel.
can any one have any Idea how I can achieve this.

Thanks
Vijendra

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Apr 2013, 04:08 AM
Hi,

Try hiding the column before exportng as shown below.
c#;
protected void Button1_Click(object sender, EventArgs e)
{
        RadGrid1.MasterTableView.GetColumn("UniqueName1").Visible = false;
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.OpenInNewWindow = true;
        RadGrid1.MasterTableView.ExportToExcel();
}
Thanks,
Shinu
0
Vij
Top achievements
Rank 1
answered on 11 Apr 2013, 01:39 PM
This will hide the column from the exported Excel, even I want just of it's reserve,
On UI 2-3 columns will display, but when user export the data in excel all 25 columns will be in excel file.
0
Shinu
Top achievements
Rank 2
answered on 12 Apr 2013, 05:04 AM
Hi,

You can set the column's Display property as false and show them while exporting.
aspx:
<telerik:GridBoundColumn Display="false" DataField="ShipAddress" UniqueName="ShipAddress" ></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="OrderID" Display="false" UniqueName="OrderID"></telerik:GridBoundColumn>
c#:
protected void Button1_Click(object sender, EventArgs e)
{
        RadGrid1.MasterTableView.GetColumn("OrderID").Visible = true;
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.OpenInNewWindow = true;
        RadGrid1.MasterTableView.ExportToExcel();
}
Thanks,
Shinu
Tags
Grid
Asked by
Vij
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Vij
Top achievements
Rank 1
Share this question
or