【问题标题】:Export boolean columns from the telerik RadGridView in wpf从 wpf 中的 Telerik RadGridView 导出布尔列
【发布时间】:2014-04-11 21:18:37
【问题描述】:

RadGridView 的项目源是类,网格有大约 20 列,其中 2 列是布尔列。如果值为 true,则在 bool 列中显示图像。

              public bool IsPassed {get;set;}
              pulbic bool HasStructNumber {get;set;}

当我导出到 excel 时,如果上面的值是真的,我想显示一个像“*”这样的字符串。如何做到这一点?

public static string ToExcelML(this GridViewDataControlsource,IEnumerable items, bool includeHeader, bool includeFooter);

从 RadGridView 实例调用此方法。

      RadGridView rg;
     rg.ToExcelML(grid.SelectedItems, true, false);

【问题讨论】:

    标签: wpf xaml export-to-excel telerik-grid radgridview


    【解决方案1】:

    为了不覆盖标题,您需要仅在 e.Element 为 ExportElement.Cell 时更改 e.Value。

    private void clubsGrid_ElementExporting(object sender,GridViewElementExportingEventArgs e)
      {
       if (e.Element == ExportElement.Cell)
         {
           var column = e.Context as GridViewDataColumn;
           if (column != null && column.Header.ToString()=="IsPassed")
             {
                if (e.Value == true)
                 {
                   e.Value = "Yes";
                 }
           }
       }
    

    }

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多