gpt4 book ai didi

asp.net - 超链接数据未在 radgrid excel 导出中导出

转载 作者:行者123 更新时间:2023-12-04 20:43:41 25 4
gpt4 key购买 nike

我在 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();

页面:




'>



    <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>

最佳答案

找到了解决此问题的方法。您必须先在超链接上设置文本,然后才能在 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;
}
}

关于asp.net - 超链接数据未在 radgrid excel 导出中导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25639484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com