Spread for ASP.NET 表格控件 MVC5 教程 - 接口调用

发布时间:2015/09/27 00:09 发布者:iceman

返回博客中心

在上一篇文章 Spread for ASP.NET 表格控件 MVC5 教程 - Hello World 中我们阐述了如何在 MVC5 中添加 Spread 表格控件,在本篇文章中我们将阐述如何在 MVC5 中调用 Spread 接口。

可以根据上一篇文章在MVC5应用中初始化 Spread 表格控件,效果图如下:

image

1.我们可以在视图页面中通过以下代码操作 Spread 控件:

            @Html.FpSpread("FpSpread1",x=>{
               x.Height = 500;
               x.Width = 800;
               x.ActiveSheetView.Cells[0, 0].Text = "视图页面测试";
            });

 

效果图:

image

2.添加 Spread 事件,Spread 在MVC中允许添加 Init、Load 和 PreRender 事件。下面我们以 Load 事件为例进行展示:

在控制器中添加 Spread Load 事件,操作Spread属性,不需要额外的操作只需要 事件名称包含视图中 Spread 控件 ID即可:

        public void FpSpread1_Load(object sender, EventArgs e)
        {
            FarPoint.Mvc.Spread.FpSpread spread = sender as FarPoint.Mvc.Spread.FpSpread;
            spread.ActiveSheetView.Cells[0, 1].Text = "控制器中操作Spread";
        }

 

效果图:

image

或者可以通过以下方法添加 Spread 事件:

        [FarPoint.Mvc.Spread.MvcSpreadEvent("Load", "FpSpread1")]
        public void _load(object sender, EventArgs e)
        {
            FarPoint.Mvc.Spread.FpSpread spread = sender as FarPoint.Mvc.Spread.FpSpread;
            spread.ActiveSheetView.Cells[0, 1].Text = "控制器中操作Spread";
        }

 

以上即为 MVC 中 操作Spread表格控件的方法:

Demo下载:

http://www.grapecity.com.cn/livesamples/temp/SpreadWMVC5_API.zip

 

了解 Spread 表格控件更多功能请参考:

/developer/spread-aspnet
 

关于葡萄城

赋能开发者!葡萄城是专业的集开发工具、商业智能解决方案、低代码开发平台于一身的软件和服务提供商,为超过 75% 的全球财富 500 强企业提供服务。葡萄城专注控件软件领域30年,希望通过模块化的开发控件、灵活的低代码应用开发平台等一系列开发工具、解决方案和服务,帮助开发者快速响应复杂多变的业务需求,最大程度地发挥开发者的才智和潜能,让开发者的 IT 人生更从容更美好。

了解详情,请访问葡萄城官网