Spreadfor ASP.NET 6.0产品中提供了固定行与固定列的功能,用户只需设置以下两行代码就可以实现:
  1.     this.FpSpread1.Sheets[0].FrozenRowCount = 2;
  2.     this.FpSpread1.Sheets[0].FrozenColumnCount = 2;
复制代码
在Spread中实现固定行与固定列的基本思想是,将SheetView拆分为多个<Table>进行显示,并将交界的边线进行加粗显示,比如下面的效果:


在某些情况下,我们可能不需要交界处的边线加粗显示,而是与其它表格线显示一样的粗细,此时我们就的对SheetView拆分之后的<Table>进行一些特殊的样式设置,将viewport和viewport1的左边框隐藏,viewport和viewport2的上边框隐藏,而这一过程我们都放到Render中来实现,代码如下:
 
protected override void Render(HtmlTextWriter writer)
    {
        Table frozenTable1 = this.FpSpread1.FindControl("viewport1") as Table;

        if (frozenTable1 != null)
        {
            frozenTable1.Style.Value = "border-bottom: Black  1px solid; position: " +

                "relative; border-left: Black  0px solid; width: 1px; border-collapse:" +

                " collapse; table-layout: fixed; border-top: Black  1px solid; top: 0px;" +

                " cursor: default; border-right: Black  1px solid;";
        }

        Table frozenTable2 = this.FpSpread1.FindControl("viewport2") as Table;

        if (frozenTable2 != null)
        {
            frozenTable2.Style.Value = "border-bottom: Black  1px solid; position: " +

                "relative; border-left: Black  1px solid; width: 1px; border-collapse:" +

                " collapse; table-layout: fixed; border-top: Black  0px solid; top: 0px;" +

                " cursor: default; border-right: Black  1px solid;";
        }

        Table frozenTable = this.FpSpread1.FindControl("viewport") as Table;

        if (frozenTable != null)
        {
            frozenTable.Style.Value = "border-bottom: Black  1px solid; position: " +

                "relative; border-left: Black  0px solid; width: 1px; border-collapse:" +

                " collapse; table-layout: fixed; border-top: Black  0px solid; top: 0px;" +

                " cursor: default; border-right: Black  1px solid;";
        }

        base.Render(writer);

    }
复制代码


源码下载:VS2010 + Spread for ASP.NET 6.0 + IE8.0
5363_Frozen.zip (9.73 K, 下载次数:8)