在 Spread for ASP.NET 产品中提供了常用的单元格类型,此外,还通过
FarPoint.Web.Spread.Extender.dll 提供了对 Ajax 的支持,比如通过 DateCalendarCellType 单元格类型就可以使用 Ajax Control Toolkit 中的日历控件,之前已经有文章介绍了如何在Spread项目中使用 Ajax Control Toolkit,今天我们主要讲一讲如何将英文的日历控件修改为中文显示。
其实操作很简单,我们只需按照以下不知操作即可:
1、在工程中添加 FarPoint.Web.Spread.Extender.dll 的引用
2、在工程中添加AjaxControlToolkit.dll的引用,注意Spread使用的AjaxControlToolkit版本为 3.0.30930
3、设置aspx页面Document的 Culture和 UICulture 属性为auto或者zh-CN Chinese (People's Republic of China)
4、设置页面中ScriptManager的EnableScriptGlobalization和EnableScriptLocalization = true
5、在后台代码中为单元格设置 DateCalendarCellType 单元格类型:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FarPoint.Web.Spread.Extender.DateCalendarCellType dcct = new FarPoint.Web.Spread.Extender.DateCalendarCellType(); FpSpread1.ActiveSheetView.Columns[1].CellType = dcct; } }
注意:在Build工程时,会将AjaxControlToolkit的资源dll一块包含到工程的 bin 目录中,可以看到有 zh-CHS、zh-CHT等
源码下载:VS2010 + Spread .NET 6.0 + AjaxControlToolkit 3.0.30930