Hi Kavitha,
Please try the sample code snippet to export footer to excel.
ASPX:
C#:
protected
void
RadGrid1_NeedDataSource(
object
source, GridNeedDataSourceEventArgs e)
{
DataTable table =
new
DataTable();
table.Columns.Add(
"ProductName"
);
table.Columns.Add(
"Price"
,
typeof
(
double
));
table.Columns.Add(
"Manufacturer"
);
table.Rows.Add(
"Futo maki"
, 12.44,
"Osaka Nihonbashi"
);
table.Rows.Add(
"Musaka"
, 10.61,
"Sofiiski gozbi"
);
table.Rows.Add(
"Cheesezer"
, 9.50,
"Burger mafia"
);
RadGrid1.DataSource = table;
}
protected
void
RadGrid1_ExcelMLExportRowCreated(
object
source, GridExportExcelMLRowCreatedArgs e)
{
if
(e.Worksheet.Table.Rows.Count == RadGrid1.Items.Count + 1)
{
RowElement row =
new
RowElement();
GridFooterItem footer = (source
as
RadGrid).MasterTableView.GetItems(GridItemType.Footer)[0]
as
GridFooterItem;
foreach
(GridColumn column
in
(source
as
RadGrid).MasterTableView.Columns)
{
CellElement cell =
new
CellElement();
string
cellText = footer[column.UniqueName].Text;
cell.Data.DataItem = cellText ==
" "
?
""
: cellText;
row.Cells.Add(cell);
}
e.Worksheet.Table.Rows.Add(row);
}
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.ExportToExcel();
}
Thanks,
Princy