static void FilterTextByCondition(Workbook workbook) { #region #FilterTextByCondition Worksheet worksheet = workbook.Worksheets["Regional sales"]; workbook.Worksheets.ActiveWorksheet = worksheet; // Enable filtering for the "B2:E23" cell range. CellRange range = worksheet["B2:E23"]; worksheet.AutoFilter.Apply(range); // Filter values in the "Product" column that contain "Gi" and include empty cells. AutoFilterColumn products = worksheet.AutoFilter.Columns[1]; products.ApplyCustomFilter("*Gi*", FilterComparisonOperator.Equal, FilterValue.FilterByBlank, FilterComparisonOperator.Equal, false); #endregion #FilterTextByCondition }
static void FilterNumericByCondition(Workbook workbook) { #region #FilterNumbersByCondition Worksheet worksheet = workbook.Worksheets["Regional sales"]; workbook.Worksheets.ActiveWorksheet = worksheet; // Enable filtering for the "B2:E23" cell range. CellRange range = worksheet["B2:E23"]; worksheet.AutoFilter.Apply(range); // Filter values in the "Sales" column that are in a range from 5000$ to 8000$. AutoFilterColumn sales = worksheet.AutoFilter.Columns[2]; sales.ApplyCustomFilter(5000, FilterComparisonOperator.GreaterThanOrEqual, 8000, FilterComparisonOperator.LessThanOrEqual, true); #endregion #FilterNumbersByCondition }
static void FilterNumericByCondition(IWorkbook workbook) { workbook.LoadDocument("Documents\\SalesReport.xlsx"); workbook.BeginUpdate(); try { Worksheet worksheet = workbook.Worksheets["Regional sales"]; workbook.Worksheets.ActiveWorksheet = worksheet; #region #FilterByCondition // Enable filtering for the specified cell range. CellRange range = worksheet["B2:E23"]; worksheet.AutoFilter.Apply(range); // Filter values in the "Sales" column that are in a range from 5000$ to 8000$. AutoFilterColumn sales = worksheet.AutoFilter.Columns[2]; sales.ApplyCustomFilter(5000, FilterComparisonOperator.GreaterThanOrEqual, 8000, FilterComparisonOperator.LessThanOrEqual, true); #endregion #FilterByCondition } finally { workbook.EndUpdate(); } }
static void FilterTextByCondition(IWorkbook workbook) { workbook.LoadDocument("Documents\\SalesReport.xlsx"); workbook.BeginUpdate(); try { Worksheet worksheet = workbook.Worksheets["Regional sales"]; workbook.Worksheets.ActiveWorksheet = worksheet; #region #FilterTextByCondition // Enable filtering for the specified cell range. CellRange range = worksheet["B2:E23"]; worksheet.AutoFilter.Apply(range); // Filter values in the "Product" column that contain "Gi" and include empty cells. AutoFilterColumn products = worksheet.AutoFilter.Columns[1]; products.ApplyCustomFilter("*Gi*", FilterComparisonOperator.Equal, FilterValue.FilterByBlank, FilterComparisonOperator.Equal, false); #endregion #FilterTextByCondition } finally { workbook.EndUpdate(); } }