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

Some Columns Data missing while Exporting to excel

7 Answers 267 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 1
Joseph asked on 01 Dec 2008, 01:56 PM
I have a Grid with Link Columns.

When I export to Excel, all the data appears in the excel file except the data in the columns that are Links.

I have these Settings :

 Me.ExportSettings.ExportOnlyData = True
 Me.ExportSettings.IgnorePaging = True
  Me.ExportSettings.OpenInNewWindow = False

Is this related to ExportOnlyData being True ?

If so, How can I export the data without showing the Filters in the Excel file even if ExportOnlyData = False ?

7 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 01 Dec 2008, 03:20 PM
Hello Joseph,

I recommend you leave ExportOnlyData as false and hide the unwanted elements in the event handler of your export button.
protected void exportButton1_Click(object sender, EventArgs e) 
    foreach (GridFilteringItem item in RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)) 
        item.Visible = false
    RadGrid1.MasterTableView.ExportToExcel(); 

Let us know whether this helps.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Shinu
Top achievements
Rank 2
answered on 02 Dec 2008, 05:45 AM
Hi Joseph,

You can also set the AllowFilteringByColumn property to false in the export button's click event to prevent the filtering item from appearing in the Exported document.

 protected void LinkButton1_Click(object sender, EventArgs e) 
    { 
        RadGrid1.AllowFilteringByColumn = false
        RadGrid1.Rebind(); 
        RadGrid1.MasterTableView.ExportToExcel();  
    } 


Shinu.
0
Joseph
Top achievements
Rank 1
answered on 02 Dec 2008, 08:38 AM
Both solutions worked well.

But in the first column I have checkboxe + LINK

The checkboxes get exported too and the generated excel contains these checboxes.

Is there a way to hide these checkboxes ?
0
Joseph
Top achievements
Rank 1
answered on 02 Dec 2008, 09:03 AM
I am using this code :

Dim grid As gvAccess.Web.Controls.TelerikControls.Grid.GVWebGrid = Nothing

            grid = Me._tableView.OwnerGrid

            grid.AllowFilteringByColumn = False

            For Each item As GridItem In grid.MasterTableView.GetItems(GridItemType.Item)

                Dim chk As CheckBox = item.FindControl("CheckBoxSelect")

                If chk IsNot Nothing Then
                    chk.Visible = False
                End If
            Next


            grid.Rebind()

            grid.DefaultExport()

All Checkboxes are still visible!
0
Accepted
Princy
Top achievements
Rank 2
answered on 02 Dec 2008, 09:08 AM
Hello Joseph,

A suggestion would be to hide the column containing the checkbox and the linkbutton and instead display a column containing linkbutton and then finally export the grid. You can go through the section 'Exporting GridButtonColumn/GridTemplateColumn/GridHyperLinkColumn data' in the following help link for more details on the same.
Exporting tips and tricks

Thanks
Princy.

0
Daniel
Telerik team
answered on 02 Dec 2008, 09:24 AM
Hello Joseph,

Try the following modification:
grid.AllowFilteringByColumn = False 
grid.Rebind() 
For Each item As GridItem In grid.MasterTableView.GetItems(GridItemType.Item) 
   Dim chk As CheckBox = item.FindControl("CheckBoxSelect"
   If chk IsNot Nothing Then 
      chk.Visible = False 
   End If 
Next 
grid.DefaultExport() 

Let us know if you need further assistance.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Joseph
Top achievements
Rank 1
answered on 02 Dec 2008, 10:55 AM
Thanks for your suggestions guys.

Hiding and showing columns was the appropriate solution.

Keep up the good work!
Tags
Grid
Asked by
Joseph
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Shinu
Top achievements
Rank 2
Joseph
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or