将telerik rad网格导出为ex​​cel获取空单元格 [英] Exporting the telerik rad grid to excel getting empty cell

查看:96
本文介绍了将telerik rad网格导出为ex​​cel获取空单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有两列(Col1和Col2)的telerik RadGrid,它加载了两个值,一个整数(对于Col1)和一个来自数据库的真实(Col2)类型值。



对于导出,我已经通过这些将数字格式设置为十进制,



  protected   void  rdData_ExcelMLExportStylesCreated( object  source,GridExportExcelMLStyleCreatedArgs e)
{
StyleElement style = new StyleElement( MyNumberStyle);
style.NumberFormat.FormatType = NumberFormatType.General;
style.NumberFormat.Attributes [ ss:格式] = 0.0;
e.Styles.Add(style);
}


受保护 void rdData_ExcelMLExportRowCreated(< span class =code-keyword> object
source,GridExportExcelMLRowCreatedArgs e)
{
e.Row.Cells.GetCellByName( Col1)。StyleValue = MyNumberStyle;
e.Row.Cells.GetCellByName( Col2)。StyleValue = MyNumberStyle;

}





这是我的出口设置:



 rdData.ExportSettings.ExportOnlyData =  true ; 
rdData.ExportSettings.IgnorePaging = true ;
rdData.ExportSettings.OpenInNewWindow = true ;
rdData.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML;
rdData.MasterTableView.ExportToExcel();





我的问题是:

导出到excel时,Col1的格式为0.0(例如:1.0)

,但实际类型列为null。




请帮帮我。

解决方案

我建​​议你在telerik上提出这个问题论坛 [ ^ ]。



更多:

http://www.telerik.com/community/forums/aspnet-ajax/grid/telerik-radgrid-export-to- excel.aspx [ ^ ]

http://demos.telerik.com/aspnet-ajax/grid/examples/export/biffexport/defaultcs.aspx [ ^ ]

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting /defaultcs.aspx [ ^ ]

I am having a telerik RadGrid with two columns (Col1 and Col2 ) and it is loaded with two values, one integer ( for Col1 ) and one real ( Col2) type values from database.

For exporting , I have made number format to decimal through these,

protected void rdData_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
{
    StyleElement style = new StyleElement("MyNumberStyle");
    style.NumberFormat.FormatType = NumberFormatType.General;
    style.NumberFormat.Attributes["ss:Format"] = "0.0";
    e.Styles.Add(style);
}


protected void rdData_ExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e)
{
    e.Row.Cells.GetCellByName("Col1").StyleValue = "MyNumberStyle";
    e.Row.Cells.GetCellByName("Col2").StyleValue = "MyNumberStyle";

}



Here is my export setting:

rdData.ExportSettings.ExportOnlyData = true;
rdData.ExportSettings.IgnorePaging = true;
rdData.ExportSettings.OpenInNewWindow = true;       
rdData.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML;        
rdData.MasterTableView.ExportToExcel();



My question is :
While exporting to excel the Col1 is formatted with 0.0 ( ex : 1.0 )
but the real type column is getting as null.


Please help me.

解决方案

I suggest you to ask this question on telerik forum[^].

More:
http://www.telerik.com/community/forums/aspnet-ajax/grid/telerik-radgrid-export-to-excel.aspx[^]
http://demos.telerik.com/aspnet-ajax/grid/examples/export/biffexport/defaultcs.aspx[^]
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx[^]


这篇关于将telerik rad网格导出为ex​​cel获取空单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆