问题二:
“设置execl 的下来筛选条件”Spread中提供了三种数据过滤方式(Spread 数据过滤),比如通过以下代码可以实现类似于Excel的过滤功能:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- FpSpread1.OpenExcel(Server.MapPath("综合周报.xls"));
- FpSpread1.Sheets[0].AllowPage = false;
- FpSpread1.Sheets[0].AutoFilterMode = FarPoint.Web.Spread.AutoFilterMode.Enhanced;
- FarPoint.Web.Spread.IRowFilter rowFilter = new FarPoint.Web.Spread.HideRowFilter(FpSpread1.Sheets[0]);
- // add a FilterColumnDefinition for Columns[3]
- FarPoint.Web.Spread.FilterColumnDefinition fd0 = new FarPoint.Web.Spread.FilterColumnDefinition(0, FarPoint.Web.Spread.FilterListBehavior.Default);
- FarPoint.Web.Spread.FilterColumnDefinition fd3 = new FarPoint.Web.Spread.FilterColumnDefinition(1, FarPoint.Web.Spread.FilterListBehavior.Default);
- FarPoint.Web.Spread.FilterColumnDefinition fd4 = new FarPoint.Web.Spread.FilterColumnDefinition(2, FarPoint.Web.Spread.FilterListBehavior.Default);
- FarPoint.Web.Spread.FilterColumnDefinition fd5 = new FarPoint.Web.Spread.FilterColumnDefinition(3, FarPoint.Web.Spread.FilterListBehavior.Default);
- FarPoint.Web.Spread.FilterColumnDefinition fd6 = new FarPoint.Web.Spread.FilterColumnDefinition(4, FarPoint.Web.Spread.FilterListBehavior.Default);
- rowFilter.ColumnDefinitions.Add(fd0);
- rowFilter.ColumnDefinitions.Add(fd3);
- rowFilter.ColumnDefinitions.Add(fd4);
- rowFilter.ColumnDefinitions.Add(fd5);
- rowFilter.ColumnDefinitions.Add(fd6);
- FpSpread1.Sheets[0].RowFilter = rowFilter;
- }
- }
复制代码
三种过滤实现的完整代码可以参考 |