【问题标题】:Ultragrid infragistics excel export exporting UltraDropDownList ValueMember not DisplayMemberUltragrid infragistics excel 导出导出 UltraDropDownList ValueMember 不是 DisplayMember
【发布时间】:2015-01-22 11:35:20
【问题描述】:

我正在使用 Infragistics.Documents.Excel 将 UltraGrid 导出到 Excel。网格包含各种列,其中之一是绑定到数据源的 DropDownList 类型。但是,当它导出到 Excel 时,它会很好地显示列,但是 excel 字段中的数据是 ValueMember,例如 1、2、3、4,而不是 DisplayMember,例如“Book”。有谁知道解决这个问题的方法吗?

谢谢,

【问题讨论】:

  • 我为此使用了以下解决方法,方法是使用此 DropDownList 的文本值填充另一个隐藏列并隐藏 DropDownList 列并在导出网格之前仅显示隐藏文本列。

标签: c# excel infragistics ultrawingrid


【解决方案1】:

您可以处理 UltraGridExcelExporter 组件的 ExportedStarted 事件,其中创建了 UltraGrid 布局的副本,获取您知道的 ValueList 并将每个项目集显示成员转换为字符串的数据值。

private void ultraGridExcelExporter1_ExportStarted(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.ExportStartedEventArgs e)
{
        ValueList valueList = e.Layout.Bands[0].Columns[0].ValueList as ValueList;

        foreach (var item in valueList.ValueListItems)
        {
            item.DisplayText = item.DataValue.ToString();
        }
}

【讨论】:

    猜你喜欢
    • 2012-06-08
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-16
    相关资源
    最近更新 更多