Unplanned
Last Updated: 01 Jun 2020 16:00 by ADMIN
Shamalee
Created on: 27 Sep 2016 23:10
Category: Grid
Type: Feature Request
4
Avoid extra row after head in exported spreadsheet (RadGrid)
This feature request is regarding the ExportToExcel button in Radgrid.

ExportToExcel button in Radgrid adds an extra row in the exported excel sheet. This is due to the presence of Filtering items.

Export to Excel code in radgrid:

<ExportSettings ExportOnlyData="true" IgnorePaging="true" Excel-Format="Biff" OpenInNewWindow="True">
<Excel Format="Biff" AutoFitImages="True"></Excel>
        </ExportSettings>
<CommandItemSettings ShowAddNewRecordButton="False" ShowRefreshButton="False" ShowExportToExcelButton="True" ExportToExcelText="Export Grid To Excel"/>

The above code produces an extra row.

I know there is a fix by disabling the Filtering items in the grid in OnItemCommand event. So I used that. The code is given below:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.ExportToExcelCommandName)
            {
                ReviewByCollegeGrid.AllowFilteringByColumn = false;
                ReviewByCollegeGrid.Rebind();
                ReviewByCollegeGrid.ExportSettings.Excel.Format = GridExcelExportFormat.Biff;
                ReviewByCollegeGrid.ExportSettings.IgnorePaging = true;
                ReviewByCollegeGrid.ExportSettings.ExportOnlyData = true;
                ReviewByCollegeGrid.ExportSettings.OpenInNewWindow = true;
            }
        }
But it is a lot of work when you have to do it for all the web pages in your application. Please provide a feature which will help to solve this issue in an easier way.
0 comments