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

Export Undisplayed (in UI) Columns to Excel

3 Answers 27 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Staci
Top achievements
Rank 1
Staci asked on 11 Nov 2008, 12:19 AM
I have a situation where I'd like to display, in the exported Excel spreadsheet, several columns which have a style of "display:none". Is this possible and how would one go about this?

example:

 

<telerik:GridBoundColumn DataField="acct_first_name" HeaderText="First Name" Display="false" UniqueName="acct_first_name" />

Or, how would I display each data item in a GridTemplateColumn as a separate cell in Excel once it's exported?
example:
<telerik:GridTemplateColumn UniqueName="Acct_full_address"><HeaderTemplate>
<div id="Div2" runat="server"> Full Address</div>
</HeaderTemplate>
<ItemTemplate>
<div>

<%# Eval("acct_first_name") %><%# Eval("acct_last_name") %>

</div>
<div>
<%# Eval("acct_addr1") %><%# Eval("acct_addr2") %><%# Eval("acct_unit_number") %>

</div>
<div>
<% # Eval("acct_city") %>,<% # Eval("acct_state") %> <%# Eval("acct_postalcode") %><%# Eval("acct_country_code") %>

</div>
</ItemTemplate>
</telerik:GridTemplateColumn>

 

Any help would be much appreciated.

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Nov 2008, 04:33 AM
Hi,

You can set the display property of the hidden columns to true in the export button's click event as shown below.

CS:
protected void Button1_Click(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.GetColumn("acct_first_name").Display = true
        RadGrid1.ExportSettings.OpenInNewWindow = true
        RadGrid1.ExportSettings.ExportOnlyData = true
        RadGrid1.MasterTableView.ExportToExcel(); 
    } 


Thanks
Shinu.
0
Staci
Top achievements
Rank 1
answered on 11 Nov 2008, 06:16 PM
This was exactly what I needed! Thanks, Shinu!!

I was so close, yet so far.
0
Shinu
Top achievements
Rank 2
answered on 12 Nov 2008, 05:10 AM
Hi Staci,

You can also refer the following help document for getting more tips about Exporting.
Exporting tips and tricks

Shinu.
Tags
Grid
Asked by
Staci
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Staci
Top achievements
Rank 1
Share this question
or