public void Add(String elementNumber, XLSortOrder sortOrder, Boolean ignoreBlanks, Boolean matchCase) { elements.Add(new XLSortElement() { ElementNumber = XLHelper.GetColumnNumberFromLetter(elementNumber), SortOrder = sortOrder, IgnoreBlanks = ignoreBlanks, MatchCase = matchCase }); }
public void Add(Int32 elementNumber, XLSortOrder sortOrder, Boolean ignoreBlanks, Boolean matchCase) { elements.Add(new XLSortElement() { ElementNumber = elementNumber, SortOrder = sortOrder, IgnoreBlanks = ignoreBlanks, MatchCase = matchCase }); }
public void Add(String elementNumber, XLSortOrder sortOrder) { Add(elementNumber, sortOrder, true); }
public void Add(Int32 elementNumber, XLSortOrder sortOrder) { Add(elementNumber, sortOrder, true); }
public new IXLRange SortLeftToRight(XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { return(base.SortLeftToRight(sortOrder, matchCase, ignoreBlanks).AsRange()); }
public new IXLRange SortLeftToRight(XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { return base.SortLeftToRight(sortOrder, matchCase, ignoreBlanks).AsRange(); }
public new IXLRange Sort(String columnsToSortBy, XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { return(base.Sort(columnsToSortBy, sortOrder, matchCase, ignoreBlanks).AsRange()); }
public IXLRangeColumn Sort(XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { base.Sort(1, sortOrder, matchCase, ignoreBlanks); return(this); }
public XLAutoFilter Sort(Int32 columnToSortBy, XLSortOrder sortOrder, Boolean matchCase, Boolean ignoreBlanks) { var ws = Range.Worksheet as XLWorksheet; ws.SuspendEvents(); Range.Range(Range.FirstCell().CellBelow(), Range.LastCell()).Sort(columnToSortBy, sortOrder, matchCase, ignoreBlanks); Sorted = true; SortOrder = sortOrder; SortColumn = columnToSortBy; if (Enabled) { using (var rows = Range.Rows(2, Range.RowCount())) { foreach (IXLRangeRow row in rows) row.WorksheetRow().Unhide(); } foreach (KeyValuePair<int, List<XLFilter>> kp in Filters) { Boolean firstFilter = true; foreach (XLFilter filter in kp.Value) { Boolean isText = filter.Value is String; using (var rows = Range.Rows(2, Range.RowCount())) { foreach (IXLRangeRow row in rows) { Boolean match = isText ? filter.Condition(row.Cell(kp.Key).GetString()) : row.Cell(kp.Key).DataType == XLCellValues.Number && filter.Condition(row.Cell(kp.Key).GetDouble()); if (firstFilter) { if (match) row.WorksheetRow().Unhide(); else row.WorksheetRow().Hide(); } else { if (filter.Connector == XLConnector.And) { if (!row.WorksheetRow().IsHidden) { if (match) row.WorksheetRow().Unhide(); else row.WorksheetRow().Hide(); } } else if (match) row.WorksheetRow().Unhide(); } } firstFilter = false; } } } } ws.ResumeEvents(); return this; }
public new IXLRange Sort(String columnsToSortBy, XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { return GetRangeForSort().Sort(columnsToSortBy, sortOrder, matchCase, ignoreBlanks); }
public void Add(String elementNumber, XLSortOrder sortOrder, Boolean ignoreBlanks) { Add(elementNumber, sortOrder, ignoreBlanks, false); }
IXLAutoFilter IXLAutoFilter.Sort(Int32 columnToSortBy, XLSortOrder sortOrder, Boolean matchCase, Boolean ignoreBlanks) { return Sort(columnToSortBy, sortOrder, matchCase, ignoreBlanks); }
public IXLRangeColumn Sort(XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { base.Sort(1, sortOrder, matchCase, ignoreBlanks); return this; }
public XLAutoFilter Sort(Int32 columnToSortBy, XLSortOrder sortOrder, Boolean matchCase, Boolean ignoreBlanks) { if (!Enabled) { throw new ApplicationException("Filter has not been enabled."); } var ws = Range.Worksheet as XLWorksheet; ws.SuspendEvents(); Range.Range(Range.FirstCell().CellBelow(), Range.LastCell()).Sort(columnToSortBy, sortOrder, matchCase, ignoreBlanks); Sorted = true; SortOrder = sortOrder; SortColumn = columnToSortBy; if (Enabled) { using (var rows = Range.Rows(2, Range.RowCount())) { foreach (IXLRangeRow row in rows) { row.WorksheetRow().Unhide(); } } foreach (KeyValuePair <int, List <XLFilter> > kp in Filters) { Boolean firstFilter = true; foreach (XLFilter filter in kp.Value) { Boolean isText = filter.Value is String; using (var rows = Range.Rows(2, Range.RowCount())) { foreach (IXLRangeRow row in rows) { Boolean match = isText ? filter.Condition(row.Cell(kp.Key).GetString()) : row.Cell(kp.Key).DataType == XLCellValues.Number && filter.Condition(row.Cell(kp.Key).GetDouble()); if (firstFilter) { if (match) { row.WorksheetRow().Unhide(); } else { row.WorksheetRow().Hide(); } } else { if (filter.Connector == XLConnector.And) { if (!row.WorksheetRow().IsHidden) { if (match) { row.WorksheetRow().Unhide(); } else { row.WorksheetRow().Hide(); } } } else if (match) { row.WorksheetRow().Unhide(); } } } firstFilter = false; } } } } ws.ResumeEvents(); return(this); }
public new IXLRow SortLeftToRight(XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { base.SortLeftToRight(sortOrder, matchCase, ignoreBlanks); return(this); }
IXLBaseAutoFilter IXLBaseAutoFilter.Sort(Int32 columnToSortBy, XLSortOrder sortOrder, Boolean matchCase, Boolean ignoreBlanks) { return(Sort(columnToSortBy, sortOrder, matchCase, ignoreBlanks)); }
public new IXLRange Sort(Int32 columnToSortBy, XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { return base.Sort(columnToSortBy, sortOrder, matchCase, ignoreBlanks).AsRange(); }
public new IXLRange Sort(String columnsToSortBy, XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { var toSortBy = new StringBuilder(); foreach (string coPairTrimmed in columnsToSortBy.Split(',').Select(coPair => coPair.Trim())) { String coString; String order; if (coPairTrimmed.Contains(' ')) { var pair = coPairTrimmed.Split(' '); coString = pair[0]; order = pair[1]; } else { coString = coPairTrimmed; order = "ASC"; } Int32 co; if (!Int32.TryParse(coString, out co)) co = Field(coString).Index + 1; toSortBy.Append(co); toSortBy.Append(" "); toSortBy.Append(order); toSortBy.Append(","); } return DataRange.Sort(toSortBy.ToString(0, toSortBy.Length - 1), sortOrder, matchCase, ignoreBlanks); }
public new IXLRow SortLeftToRight(XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true) { base.SortLeftToRight(sortOrder, matchCase, ignoreBlanks); return this; }
public XLAutoFilter Sort(Int32 columnToSortBy, XLSortOrder sortOrder, Boolean matchCase, Boolean ignoreBlanks) { if (!Enabled) { throw new InvalidOperationException("Filter has not been enabled."); } var ws = Range.Worksheet as XLWorksheet; ws.SuspendEvents(); Range.Range(Range.FirstCell().CellBelow(), Range.LastCell()).Sort(columnToSortBy, sortOrder, matchCase, ignoreBlanks); Sorted = true; SortOrder = sortOrder; SortColumn = columnToSortBy; // Recalculate shown / hidden rows if (Enabled) { using (var rows = Range.Rows(2, Range.RowCount())) { foreach (IXLRangeRow row in rows) { row.WorksheetRow().Unhide(); } } foreach (var kp in Filters) { Boolean firstFilter = true; foreach (XLFilter filter in kp.Value) { var condition = filter.Condition; var isText = filter.Value is String; var isDateTime = filter.Value is DateTime; using (var rows = Range.Rows(2, Range.RowCount())) { foreach (IXLRangeRow row in rows) { //TODO : clean up filter matching - it's done in different place Boolean match; if (isText) { match = condition(row.Cell(kp.Key).GetFormattedString()); } else if (isDateTime) { match = row.Cell(kp.Key).DataType == XLDataType.DateTime && condition(row.Cell(kp.Key).GetDateTime()); } else { match = row.Cell(kp.Key).DataType == XLDataType.Number && condition(row.Cell(kp.Key).GetDouble()); } if (firstFilter) { if (match) { row.WorksheetRow().Unhide(); } else { row.WorksheetRow().Hide(); } } else { if (filter.Connector == XLConnector.And) { if (!row.WorksheetRow().IsHidden) { if (match) { row.WorksheetRow().Unhide(); } else { row.WorksheetRow().Hide(); } } } else if (match) { row.WorksheetRow().Unhide(); } } } firstFilter = false; } } } } ws.ResumeEvents(); return(this); }