我在radgrid中有两个超链接列,当我尝试将其导出到excel时,excel表中的列是空白的,如果我使用excelML我的日期列显示时间我无法改变它,请帮帮我,在此先感谢。
RadGrid11.MasterTableView.AllowFilteringByColumn = false; RadGrid11.MasterTableView.AllowPaging = false;
RadGrid11.ExportSettings.ExportOnlyData = true;
RadGrid11.HeaderStyle.Font.Bold = true;
RadGrid11.HeaderStyle.BorderWidth = 5;
RadGrid11.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
RadGrid11.ExportSettings.FileName = "Batch";
RadGrid11.MasterTableView.GetColumn("SelectColumnID").Visible = false;
//RadGrid11.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
RadGrid11.MasterTableView.ExportToExcel();
aspx页面:
“>
<telerik:GridTemplateColumn DataField="MemberName" HeaderText="Member Name" SortExpression="MemberName" UniqueName="MemberName" >
<HeaderStyle HorizontalAlign="Center" CssClass="RadG" Width="130px" VerticalAlign="Top"/>
<ItemStyle Font-Names="Times New Roman" HorizontalAlign="Left" Font-Size="10px" Font-Bold="false" />
<ItemTemplate>
<asp:LinkButton ID="hpLinkName" runat="server" ForeColor="Blue" Font-Underline="true"
Text='<%#Eval("MemberName")%>'>
</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
答案 0 :(得分:1)
为此找到了解决方法。您必须首先在超链接上设置文本,然后才能在RadGrid1_ItemCommand函数中的导出上设置值。参见下面的示例。
private void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
{
// get the unique name of the column to grab the control
var hyperlink = item.FindControl("UniqueColumnName") as HyperLink;
if (hyperlink == null)
{
continue;
}
// set the value of the cell being exported
// to the value of the hyperlink text
item["TemplateColumn"].Text = hyperlink.Text;
}
}