
Murilo Savi
Top achievements
Rank 1
Murilo Savi
asked on 12 Mar 2014, 05:04 PM
I would like to add a column in excel generated with the day's date, plus the name of the report. I found no matter how to do, could someone help?
4 Answers, 1 is accepted
0
Hi Murilo,
Dynamically adding a column when exporting is triggered is possible by subscribing to the OnItemCommand event and including such as demonstrated below:
Note that in order to populate the values for that new column you should subscribe to the OnItemDataBound as well.
In attachments you can find a sample website which illustrates an implementation of such a scenario. The logic in the sample will add a new column and populate it with the current date.
Regards,
Angel Petrov
Telerik
Dynamically adding a column when exporting is triggered is possible by subscribing to the OnItemCommand event and including such as demonstrated below:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName ==
"ExportToExcel"
)
{
RadGrid1.MasterTableView.Columns.Add(
new
GridBoundColumn()
{
UniqueName=
"currentDate"
,
HeaderText =
"currentDate"
});
RadGrid1.Rebind();
}
}
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
GridDataItem item = e.Item
as
GridDataItem;
if
(item !=
null
&& item.OwnerTableView.GetColumnSafe(
"currentDate"
)!=
null
)
{
item[
"currentDate"
].Text = DateTime.Now.ToString();
}
}
In attachments you can find a sample website which illustrates an implementation of such a scenario. The logic in the sample will add a new column and populate it with the current date.
Regards,
Angel Petrov
Telerik
DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.
0

Murilo Savi
Top achievements
Rank 1
answered on 17 Mar 2014, 12:36 PM
RadGrid1.MasterTableView and
RadGrid1_ItemDataBound not exist on pivotgrid.
RadGrid1_ItemDataBound not exist on pivotgrid.
0
Hello Murilo,
Please accept my apologies for misunderstanding the requirement.
The code I provided in my previous post will work when the content of a RadGrid is being exported. However the same can not be achieved when RadPivotGrid is used. The reason for this is that the pivot structure is more complex than that of the grid. For now you can only export the visible content of the RadPivotGrid.
Regards,
Angel Petrov
Telerik
Please accept my apologies for misunderstanding the requirement.
The code I provided in my previous post will work when the content of a RadGrid is being exported. However the same can not be achieved when RadPivotGrid is used. The reason for this is that the pivot structure is more complex than that of the grid. For now you can only export the visible content of the RadPivotGrid.
Regards,
Angel Petrov
Telerik
DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.
0

Murilo Savi
Top achievements
Rank 1
answered on 19 Mar 2014, 04:45 PM
ok, thankz