【发布时间】:2015-06-13 13:21:14
【问题描述】:
我目前正在构建一个在 Telerik RadGrid 中包含大量数据的 asp.net 应用程序。我的网格中的许多列包含大量文本。为了限制这些列中文本的大小(并保留网格的格式),我在以下代码段中截断了 ItemDataBound(...) 方法中的每个字段:
if (item["Title"].Text.Length > 21)
item["Title"].Text = item["Title"].Text.Substring(0, 21);
if (item["Investigation_Results"].Text.Length > 30)
item["Investigation_Results"].Text = item["Investigation_Results"].Text.Substring(0, 30);
if (item["Resolution_Steps"].Text.Length > 30)
item["Resolution_Steps"].Text = item["Resolution_Steps"].Text.Substring(0, 30);
问题是当使用 RadGrid 的 Excel 导出功能时,被截断的字段在导出的 csv 中也会被截断。
问:如何在网格视图中截断数据,但在导出到 Excel 时完整?
其他信息:
在此按钮单击事件上调用导出:
protected void imgbtnexcel_Click(object sender, ImageClickEventArgs e)
{
ConfigureExport();
RadGridActionItem.MasterTableView.ExportToExcel();
}
protected void ConfigureExport()
{
RadGridActionItem.ExportSettings.ExportOnlyData = true;
RadGridActionItem.ExportSettings.IgnorePaging = true;
RadGridActionItem.ExportSettings.OpenInNewWindow = true;
}
【问题讨论】:
-
在 FarPoint 中,我可以做一个从文本继承的自定义单元格类型,然后在不实际更改值的情况下覆盖它“显示”值的方式。
标签: c# asp.net telerik export-to-excel telerik-grid