Spread.Sheets
行フィルタの結果の取得

行フィルタの結果についての情報を取得できます。

コードの使用

次のサンプルコードは、行フィルタの結果を取得します。

JavaScript
コードのコピー

$(function () {
            var spread = new GC.Spread.Sheets.Workbook($("#ss")[0]);
            var activeSheet = spread.getActiveSheet();
            activeSheet.setRowCount(7);
            activeSheet.setValue(0, 0, "North");
            activeSheet.setValue(1, 0, "South");
            activeSheet.setValue(2, 0, "East");
            activeSheet.setValue(3, 0, "South");
            activeSheet.setValue(4, 0, "North");
            activeSheet.setValue(5, 0, "North");
            activeSheet.setValue(6, 0, "West");
            activeSheet.setColumnWidth(0, 80);

            //行フィルタを設定します。
            activeSheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(0, 0, 7, 1)));

            $("#button1").click(function () {
                var rowFilter = spread.getActiveSheet().rowFilter();
                //*********************************************
                //列1がフィルタリングされていない場合は終了します。
                //*********************************************
                if (!rowFilter.isFiltered(0)) {
                    return;
                }

                //*********************************************
                //フィルタリングされた文字列
                //*********************************************
                var filterItems = rowFilter.getFilterItems(0);
                var str = "Filtered strings:";
                filterItems.forEach(function (item) {
                    str += " " + item.expected();
                })

                console.log(str);
                console.log("");

                //*********************************************
                //フィルタイン行(表示)の数
                //*********************************************
                var range = rowFilter.range;
                var filteredInRows = [], filteredOutRows = [];
                for (var i = range.row, last = range.row + range.rowCount; i < last; i++) {
                    if (rowFilter.isRowFilteredOut(i)) {
                        filteredOutRows.push(i);
                    } else {
                        filteredInRows.push(i);
                    }
                }
                console.log("Number of Filtered-In (displayed) rows: " + filteredInRows.length);
                console.log("");

                //*********************************************
                //フィルタアウト行(非表示)の数
                //*********************************************
                console.log("Number of Filtered-Out (hidden) rows: " + filteredOutRows.length);
                console.log("");

                filteredOutRows.forEach(function(item){
                    console.log("Filtered-Out (hidden) row index: " + item);
                });
                console.log("");

                //*********************************************
                //フィルタイン行(表示)/フィルタアウト行(非表示)
                //*********************************************
                filteredOutRows.forEach(function(item){
                    console.log("Data of Filtered-Out (hidden) row: " + activeSheet.getValue(item, 0));
                });
                console.log("");
                filteredInRows.forEach(function(item){
                    console.log("Data of Filtered-In (displayed) row: " + activeSheet.getValue(item, 0));
                });
            });         
        })

参照

 

 


© 2016-2018, GrapeCity inc. All rights reserved.