FarPoint.Spread.for.ASP.NET总结

FarPoint.Spread.for.ASP.NET总结_第1张图片

非常好用的web网格控件,以前做c/s时用过他的for windows版就很好用。现在改做web了有想起了它,昨天找到了破解版,和大家分享一下,我总结一下他的用法和一些属性,供大家参考。

下载地址:

第一部分:http://download.csdn.net/source/1592025

第二部分:http://download.csdn.net/source/1593174

第三部分:http://download.csdn.net/source/1593211

第四部分:http://download.csdn.net/source/1593216

里面有注册机,安装好了以后有大量的例子。非常强大.

 

单元格求和:

      fpSpread1.ActiveSheetView.Cells[0, 2].Formula = "SUM(D1:F1)";
      fpSpread1.ActiveSheetView.Cells[1, 2].Formula = "SUM(D2:F2)";
      fpSpread1.ActiveSheetView.Cells[2, 2].Formula = "SUM(D3:F3)";
      fpSpread1.ActiveSheetView.Cells[3, 2].Formula = "SUM(D4:F4)";

      //Set column formulas
      fpSpread1.ActiveSheetView.Cells[4, 2].Formula = "SUM(C1:C4)";
      fpSpread1.ActiveSheetView.Cells[4, 3].Formula = "SUM(D1:D4)";
      fpSpread1.ActiveSheetView.Cells[4, 4].Formula = "SUM(E1:E4)";
      fpSpread1.ActiveSheetView.Cells[4, 5].Formula = "SUM(F1:F4)";

 

动态列头,行头:

动态列头

添加:

        this.FpSpread1.ActiveSheetView.ColumnHeader.RowCount = 2;
        this.FpSpread1.ActiveSheetView.RowHeader.ColumnCount = 2;

合并:

     //从0行0列开始,合并2行1列

      fpSpread1.ActiveSheetView.ColumnHeaderSpanModel.Add(0, 0, 2, 1);

      fpSpread1.ActiveSheetView.ColumnHeaderSpanModel.Add(0, 1, 2, 1);

      fpSpread1.ActiveSheetView.ColumnHeaderSpanModel.Add(0, 2, 2, 1);

    //从0行3列开始,合并1行3列

      fpSpread1.ActiveSheetView.ColumnHeaderSpanModel.Add(0, 3, 1, 3);

 

动态单元格:

//合并 从第0行0列,合并4行1列

fpSpread1.ActiveSheetView.SpanModel.Add(0, 0, 4, 1);

 

冻结列,行

FpSpread1.Sheets[0].FrozenColumnCount =1;

FpSpread1.Sheets[0].FrozenRowCount=1;

 

 

在Spread中打开Excel:

 

public void OpenExcelFile(string filename)
    {
      bool ret;
      string newfilepath;

      newfilepath = pathname + filename;

      //Open
      try
      {
        ret = FpSpread1.OpenExcel(newfilepath);

        if(ret==false)
        {
          //Error opening file
          //Label2.ForeColor = Color.Red;
          //Label2.Text = "PROBLEM: Could not open file - " + newfilepath;
        }
      }
      catch(Exception ex)
      {
        //Label2.ForeColor = Color.Red;
        //Label2.Text = ex.Message.ToString();
      }
    }
 }

 

单元格类型:

 

 FpSpread1.Sheets[0].ColumnHeader.Cells[0, 0, 0, 9].CellType = new FarPoint.Web.Spread.LabelCellType();

 //图片类型

FarPoint.Web.Spread.ImageCellType imgType = new FarPoint.Web.Spread.ImageCellType("images/demo/flag_green.jpg");

      for(i=0;i        FpSpread1.Sheets[0].Cells[i, 0].CellType = imgType;

//其他类型

      FpSpread1.Sheets[0].Columns[2].CellType = new FarPoint.Web.Spread.CheckBoxCellType("格式错误");

      FarPoint.Web.Spread.IntegerCellType intcell = new FarPoint.Web.Spread.IntegerCellType("格式错误");

      FarPoint.Web.Spread.CurrencyCellType curcell = new FarPoint.Web.Spread.CurrencyCellType("格式错误");

      FarPoint.Web.Spread.RadioButtonListCellType multiType = new FarPoint.Web.Spread.RadioButtonListCellType("格式错误");

//网址类型

      FarPoint.Web.Spread.HyperLinkCellType hyperType = new FarPoint.Web.Spread.HyperLinkCellType();
      hyperType.NavigateUrl = "http:www.fpoint.com";
      FpSpread1.Sheets[0].Columns[7].CellType = hyperType;

//正则表达式

      FarPoint.Web.Spread.RegExpCellType picType = new FarPoint.Web.Spread.RegExpCellType();
      picType.ErrorMessage = "Enter a valid Phone Number - (xxx) xxx-xxxx";
      picType.ValidationExpression = "^1?//s*-?//s*(//d{3}|//(//s*//d{3}//s*//))//s*-?//s*//d{3}//s*-?//s*//d{4}$";
      FpSpread1.Sheets[0].Columns[8].CellType = picType;

底部按钮显示:

FpSpread1.CommandBar.Visible=false;

日历行点击出日历:

FarPoint.Spread.for.ASP.NET总结_第2张图片

       using System.Drawing;
       using FarPoint.Web.Spread.Extender;
       using AjaxControlToolkit;

       this.FpSpread1.ActiveSheetView.RowCount = IntRowCount;
        DateCalendarCellType dc = new DateCalendarCellType();
        MaskedEditExtender mee = new MaskedEditExtender();
        mee.Mask = "99999999";
        mee.MaskType = MaskedEditType.Number;
        dc.DateFormat = "yyyyMMdd";
        dc.Extenders.Add(mee);
        FpSpread1.ActiveSheetView.Columns[0].CellType = dc;
        FpSpread1.ActiveSheetView.Columns[0].BackColor = Color.MintCream;
        for (int i = 0; i < IntRowCount; i++)
        {
            FpSpread1.Cells[i, 0].Value = DateTime.Now.ToString("yyyyMMdd");
        }

你可能感兴趣的:(Spread,for,asp.net,第三方控件,正则表达式,exception,string,日历,file,excel)