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

Missing Column in Export to Excel

20 Answers 667 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 20 May 2008, 02:45 PM
Any idea as to why my exported excel file would be missing a column from the grid?  Here is my setup:

<ExportSettings 
     IgnorePaging="True" 
     OpenInNewWindow="True" 
     ExportOnlyData="True">
        <Excel Format="ExcelML" />
</ExportSettings>

And the column which is not showing:  (BTW, it is the first column in the grid)

<telerik:GridBoundColumn 
        DataField="market" 
        HeaderText="Market" 
        ReadOnly="True" 
        SortExpression="market"
        UniqueName="column1" 
        DataType="System.String">
            <HeaderStyle HorizontalAlign="Left" Font-Size="11px" />
            <ItemStyle Width="75px" Font-Size="11px" />
</telerik:GridBoundColumn>

I cannot see anything different between that column and all of the others that are appearing, except that this is the only column that displays text whereas all of the others display numbers.

Thank  you much,
David Martin


20 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 2
answered on 20 May 2008, 02:55 PM
I now have a hint.  I stated before that the missing column was no different from the others.  That made me go back and make sure.  Turns out this column did NOT have an aggregate whereas all the others do.  Giving the missing column an Aggregate value other than "none" now makes that column appear. 

However, I really would rather not have an aggregate on this column.  I can put a count - that wouldn't be senseless - just that it's not needed.  Besides, the aggregates, which appear in the footer, are not exported anyway.

Any idea why columns without an aggregate would be excluded from an export?

Thanks,
David
0
Konstantin Petkov
Telerik team
answered on 20 May 2008, 04:19 PM
Hello David,

This is quite an interesting report but I'm afraid we are not aware of a similar problem.

I just checked the demo below, but all the columns seem to be exported properly:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/GeneralFeatures/Exporting/DefaultCS.aspx

There are no aggregates applied there, though.

Can you please check the demo on your end? Do you get the expected exporting file? If so, can you please assemble a sample runnable project which replicates the issue? You can start a support ticket and send the sample as attachment there. Thank you in advance for your cooperation!

All the best,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
David
Top achievements
Rank 2
answered on 21 May 2008, 08:17 PM
I am still looking into it (around my schedule), but one thing that may be playing a part is that my grids are using Advanced Databinding (via NeedDataSource).  Might that be causing the problem?

As a work around to having to add an aggregate to columns where I don't want one is to set the FooterDisplayFormatString to " ". However, adding an aggregate as a work around is also a problem when the column is a templated column (can't add an aggregate to those).

As I said, I'm still looking into this using the installed Live Demos.

-David
0
Accepted
Konstantin Petkov
Telerik team
answered on 27 May 2008, 07:07 AM
Hello,

It appeared to be a problem with an IList binding in NeedDataSource which breaks the ExcelML export. We will research the problem further and do our best to resolve it internally. If anyone else hit that however, please set MasterTableView's UseAllDataFields property to true, which will resolve the problem.

Please, excuse us for the caused inconvenience.

All the best,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Sagiv Oren
Top achievements
Rank 1
answered on 30 Jul 2008, 02:28 AM
I'm having a similar problem, but in my case the first column is a GridHyperlinkColumn and the header shows up in the CSV file but the data does not.  Any thoughts?
0
Rosen
Telerik team
answered on 31 Jul 2008, 03:16 PM
Hello Sagiv Oren,

Unfortunately I have to confirm that this behavior is limitation in current version of RadGrid export to csv. But our developers has already addressed it and the fix will be available in next service pack of the RadControls for ASP.NET AJAX suite.

Meanwhile you can try setting hyperlink column's table cell text property to the value of the hyperlink control when exporting. Similar to this:

private bool _exporting = false;  
        protected void Button3_Click(object sender, System.EventArgs e)  
        {  
            ConfigureExport();  
            _exporting = true//set to true on export  
            RadGrid1.MasterTableView.ExportToCSV();  
        }  
 
        protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e)  
        {  
            // you should use ignorpaging option in order this to work  
            if (_exporting && e.Item is GridDataItem)  
            {  
                ((GridDataItem) e.Item)["CompanyName"].Text = ((HyperLink) ((GridDataItem) e.Item)["CompanyName"].Controls[0]).Text;  
            }  
        } 

Sincerely yours,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
miaufiero
Top achievements
Rank 1
answered on 29 Dec 2008, 08:02 PM
I am having a similar problem but the columns in the grid are created dynamically and the data is being ignored in multiple columns because they are hyperlink columns. Is there a solution that would fit my case?

Thanks
0
Rosen
Telerik team
answered on 30 Dec 2008, 02:56 PM
Hi miaufiero,

Can you please provide more details about your scenario and implementation? Which is the RadGrid's version you are using? To which format you are exporting? How the grid control is populated with data?

Greetings,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
miaufiero
Top achievements
Rank 1
answered on 05 Jan 2009, 12:25 PM
Thank you for your prompt reply.

Which is the RadGrid's version you are using?
RadGrid version 5.1.4.0

To which format you are exporting?
Microsoft Excel and Word

How the grid control is populated with data?
The grid is populated dynamically:

public override void CreateDynamicColumns() {
...
foreach (Example example in ExampleList) {
 string field = "EX" + example.ID;

 GridHyperLinkColumn hcol = new GridHyperLinkColumn();
 hcol.HeaderText = example.Name;
 hcol.UniqueName = field;
 hcol.DataTextField = field;
 hcol.SortExpression = field;

 hcol.DataNavigateUrlFields = new string[] { "ID_" + field };
 hcol.DataNavigateUrlFormatString = Url.EditExampleData;

 cGrid.MasterTableView.Columns.Add(hcol);
}}
0
Rosen
Telerik team
answered on 07 Jan 2009, 04:41 PM
Hi miaufiero,

Can you please check if you have set ExportOnlyData option to true? If this is the case please set it to false or you may consider using a similar to the previously proposed workaround for the CSV export.

All the best,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
miaufiero
Top achievements
Rank 1
answered on 07 Jan 2009, 05:17 PM
ExportOnlyData is set to false and therefore displays the values as hyperlinks, we do not want the data to be displayed as hyperlinks in the excel spreadsheet or word document (we only want the data to appear as link in the grid itself). If I set ExportOnlyData to true then all the data that was hyperlinks comes up blank. Since we create the columns dynamically, I cannot specify the column name as show in the example with: 

((GridDataItem) e.Item)["CompanyName"].Text = ((HyperLink) ((GridDataItem) e.Item)["CompanyName"].Controls[0]).Text;   

Can you suggest an implementation of the CSV workaround where I can traverse the dynamically created columns?

Thanks!
0
Rosen
Telerik team
answered on 08 Jan 2009, 02:36 PM
Hello miaufiero,

Basically you can iterate over RadGrid's columns collection and for each HyperLink column transform the link to text. Similar to the following:

    void RadGrid_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (_exporting && e.Item is GridDataItem)  
        {  
            foreach (GridColumn column in _grid.MasterTableView.RenderColumns)  
            {  
                if (column is GridHyperLinkColumn)  
                {  
                    ((GridDataItem)e.Item)[column.UniqueName].Text = ((HyperLink)((GridDataItem)e.Item)[column.UniqueName].Controls[0]).Text;   
                }  
            }  
        }  
    }  
    protected void Button1_Click(object sender, EventArgs e)  
    {  
        _exporting = true;  
        _grid.ExportSettings.ExportOnlyData = true;  
        _grid.ExportSettings.IgnorePaging = true;  
        _grid.MasterTableView.ExportToExcel();  
    } 


Regards,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
miaufiero
Top achievements
Rank 1
answered on 08 Jan 2009, 03:56 PM
Thanks, that worked great. Only issue I had to overcome was I wanted the links to show in the grid, just not in the exported spreadsheet/document so I had to rebind the data when the button onclick events were called.

Thanks for all your help!
0
Luc
Top achievements
Rank 1
answered on 16 Jan 2009, 01:58 AM
Hello,

We had a similar issue and the provided workaround works fine.  However, it doesn't work if the "IgnorePaging" property is set to false, since it does not call ItemDataBound.

We'd like to provide the feature to export only the current page to our customers.  Is there a way or a fix to make it work?  We are using version 2008.3 1125.

Thanks
0
Rosen
Telerik team
answered on 16 Jan 2009, 08:05 AM
Hi Luc,

In cases when IgnorePaging is set to false, you may traverse GridDataItems and apply the needed modifications before exporting. Similar to the following:

    protected void ExportButton_Click(object sender, EventArgs e)  
    {  
        GridItem[] items = RadGrid1.MasterTableView.GetItems(GridItemType.AlternatingItem, GridItemType.Item);  
        foreach (GridDataItem item in items)  
        {  
            item["HyperLinkColumn"].Text = ((HyperLink)item["HyperLinkColumn"].Controls[0]).Text;  
        }  
        RadGrid1.ExportSettings.ExportOnlyData = true;  
        RadGrid1.MasterTableView.ExportToExcel();  
    } 
 
Regards,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dev
Top achievements
Rank 1
answered on 01 Jun 2009, 06:35 PM
We are using ASPNET AJAX Q1 2009 version and still have the issue with hyperlink columns missing in the export. Any updates on the fix? Note that it is not GridHyperLinkColumn but a <asp:hyperlink> in a GridTemplateColumn.
0
Rosen
Telerik team
answered on 04 Jun 2009, 01:35 PM
Hi Gunna,

I have attached a sample project can you please check and see if I'm missing something obvious.

All the best,
Rosen
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
sln007
Top achievements
Rank 1
answered on 27 Apr 2010, 02:31 PM

Rosen,

I have a similar issue.  My missing grid column(s) is a Jumplink controlled ComboBox defined as shown below:

<telerik:GridTemplateColumn DataField="CFDA_CD" HeaderText="CFDA" SortExpression="CFDA_CD" UniqueName="CFDA_CD">  
    <ItemTemplate> 
       <asp:Label ID="LabelCFDA" runat="server" Text='<%# Eval("CFDA_CD") %>' Visible="False">  
       </asp:Label> 
       <uc1:CFDA_CD_ComboBox ID="CFDA_CD_ComboBox1" runat="server" /> 
    </ItemTemplate> 
</telerik:GridTemplateColumn> 

 

 

 

 

 

The column header is extracted, but all data for the column is "empty".

We are using RadControls for ASP.NET AJAX Q1 2010.

I've tried a variety of suggested methods found thoughout several threads in this forum, but haven't been successful yet.

Steve

 

 

 

0
Rosen
Telerik team
answered on 29 Apr 2010, 09:11 AM
Steve,

You should extract the data from your custom control and manually populate the appropriate cell as shown in the other posts in this thread.

Best wishes,
Rosen
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
sln007
Top achievements
Rank 1
answered on 29 Apr 2010, 11:58 AM
Rosen,

Thanks. 
I've used the "hidden column" trick.  I've done it before and It was suggested in another thread relating to this topic.
I have a duplicate GridBoundColumn that is normally Visible="false" until just before the ExportToExcel method call.
I just set my custom control column(s) to Visible="false", and the duplicate to Visible="true".
Tags
Grid
Asked by
David
Top achievements
Rank 2
Answers by
David
Top achievements
Rank 2
Konstantin Petkov
Telerik team
Sagiv Oren
Top achievements
Rank 1
Rosen
Telerik team
miaufiero
Top achievements
Rank 1
Luc
Top achievements
Rank 1
Dev
Top achievements
Rank 1
sln007
Top achievements
Rank 1
Share this question
or