Ejemplo n.º 1
0
        ///// <summary>
        ///// Create filter on specified column.
        ///// </summary>
        ///// <param name="column">Column code that locates a column to create filter.</param>
        ///// <param name="titleRows">Indicates how many title rows exist at the top of worksheet,
        ///// title rows will not be included in filter range.</param>
        ///// <returns>Instance of column filter.</returns>
        //public AutoColumnFilter CreateColumnFilter(string column, int titleRows = 0,
        //	AutoColumnFilterUI columnFilterUI = AutoColumnFilterUI.DropdownButtonAndPane)
        //{
        //	return CreateColumnFilter(column, column, titleRows, columnFilterUI);
        //}

        /// <summary>
        /// Create column filter.
        /// </summary>
        /// <param name="startColumn">First column specified by an address to create filter.</param>
        /// <param name="endColumn">Last column specified by an address to the filter.</param>
        /// <param name="titleRows">Indicates that how many title rows exist at the top of spreadsheet,
        /// title rows will not be included in filter apply range.</param>
        /// <param name="columnFilterUI">Indicates whether allow to create graphics user interface (GUI),
        /// by default the dropdown-button on the column and candidates dropdown-panel will be created.
        /// Set this argument as NoGUI to create filter without GUI.</param>
        /// <returns>Instance of column filter.</returns>
        public AutoColumnFilter CreateColumnFilter(string startColumn, string endColumn, int titleRows = 0,
                                                   AutoColumnFilterUI columnFilterUI = AutoColumnFilterUI.DropdownButtonAndPanel)
        {
            int startIndex = RGUtility.GetNumberOfChar(startColumn);
            int endIndex   = RGUtility.GetNumberOfChar(endColumn);

            return(CreateColumnFilter(startIndex, endIndex, titleRows, columnFilterUI));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create automatic column filter and display on specified headers of worksheet.
        /// </summary>
        /// <param name="range">Range to filter data.</param>
        /// <param name="columnFilterUI">Indicates whether or not to show GUI for filter,
        /// by default the drop-down button displayed on column header and a candidates list popuped up when dropdown-panel opened.
        /// Set this argument as NoGUI to create filter without GUI.</param>
        /// <returns>Instance of column filter.</returns>
        public AutoColumnFilter CreateColumnFilter(RangePosition range,
                                                   AutoColumnFilterUI columnFilterUI = AutoColumnFilterUI.DropdownButtonAndPanel)
        {
            var filter = new AutoColumnFilter(this, this.FixRange(range));

            filter.Attach(this, columnFilterUI);

            return(filter);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Attach filter to specified worksheet
        /// </summary>
        /// <param name="worksheet">instance of worksheet to be attached</param>
        /// <param name="uiFlag">Flags to decide which styles of GUI to be dispalyed (default is DropdownButtonAndPanel style)</param>
        public void Attach(Worksheet worksheet, AutoColumnFilterUI uiFlag = AutoColumnFilterUI.DropdownButtonAndPanel)
        {
            if (worksheet == null)
            {
                throw new ArgumentNullException("cannot attach to null worksheet", "worksheet");
            }

            this.Worksheet          = worksheet;
            this.columnFilterUIFlag = uiFlag;

            CreateFilterHeaders(this.ApplyRange.Col, this.ApplyRange.EndCol);

            worksheet.ColumnsInserted += worksheet_ColumnsInserted;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create column filter.
        /// </summary>
        /// <param name="startColumn">first column specified by a zero-based number of column to create filter</param>
        /// <param name="endColumn">last column specified by a zero-based number of column to create filter</param>
        /// <param name="titleRows">indicates that how many title rows exist at the top of spreadsheet,
        /// title rows will not be included in filter apply range.</param>
        /// <param name="columnFilterUI">Indicates whether or not to show GUI for filter,
        /// by default the drop-down button displayed on column header and a candidates list popuped up when dropdown-panel opened.
        /// Set this argument as NoGUI to create filter without GUI.</param>
        /// <returns>Instance of column filter.</returns>
        public AutoColumnFilter CreateColumnFilter(int startColumn, int endColumn, int titleRows = 0,
                                                   AutoColumnFilterUI columnFilterUI             = AutoColumnFilterUI.DropdownButtonAndPanel)
        {
            if (startColumn < 0 || startColumn >= this.ColumnCount)
            {
                throw new ArgumentOutOfRangeException("startColumn", "number of column start to filter out of valid spreadsheet range");
            }

            if (endColumn < startColumn)
            {
                throw new ArgumentOutOfRangeException("endColumn", "end column must be greater than start column");
            }

            if (endColumn >= this.ColumnCount)
            {
                throw new ArgumentOutOfRangeException("endColumn", "end column out of valid spreadsheet range");
            }

            return(CreateColumnFilter(new RangePosition(titleRows, startColumn,
                                                        this.MaxContentRow - titleRows + 1, endColumn - startColumn + 1), columnFilterUI));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Create column filter.
 /// </summary>
 /// <param name="column">Column to create filter.</param>
 /// <param name="titleRows">indicates that how many title rows exist at the top of spreadsheet,
 /// title rows will not be included in filter apply range.</param>
 /// <param name="columnFilterUI">Indicates whether allow to create graphics user interface (GUI),
 /// by default the dropdown-button on the column and candidates dropdown-panel will be created.
 /// Set this argument as NoGUI to create filter without GUI.</param>
 /// <returns>Instance of column filter.</returns>
 public AutoColumnFilter CreateColumnFilter(int column, int titleRows, AutoColumnFilterUI columnFilterUI)
 {
     return(this.CreateColumnFilter(column, column, titleRows, columnFilterUI));
 }