public CellRangeAddressList Copy() { CellRangeAddressList result = new CellRangeAddressList(); int nItems = _list.Count; for (int k = 0; k < nItems; k++) { CellRangeAddress region = (CellRangeAddress)_list[k]; result.AddCellRangeAddress(region.Copy()); } return(result); }
/** * Create an enclosing CellRange for the two cell ranges. * * @return enclosing CellRange */ public static CellRangeAddress CreateEnclosingCellRange(CellRangeAddress crA, CellRangeAddress crB) { if (crB == null) { return(crA.Copy()); } int minRow = lt(crB.FirstRow, crA.FirstRow) ? crB.FirstRow : crA.FirstRow; int maxRow = gt(crB.LastRow, crA.LastRow) ? crB.LastRow : crA.LastRow; int minCol = lt(crB.FirstColumn, crA.FirstColumn) ? crB.FirstColumn : crA.FirstColumn; int maxCol = gt(crB.LastColumn, crA.LastColumn) ? crB.LastColumn : crA.LastColumn; return(new CellRangeAddress(minRow, maxRow, minCol, maxCol)); }
/** * Create an enclosing CellRange for the two cell ranges. * * @return enclosing CellRange */ public static CellRangeAddress CreateEnclosingCellRange(CellRangeAddress crA, CellRangeAddress crB) { if (crB == null) { return crA.Copy(); } return new CellRangeAddress( lt(crB.FirstRow, crA.FirstRow) ? crB.FirstRow : crA.FirstRow, gt(crB.LastRow, crA.LastRow) ? crB.LastRow : crA.LastRow, lt(crB.FirstColumn, crA.FirstColumn) ? crB.FirstColumn : crA.FirstColumn, gt(crB.LastColumn, crA.LastColumn) ? crB.LastColumn : crA.LastColumn ); }
public void TestCopy() { CellRangeAddress ref1 = new CellRangeAddress(1, 2, 3, 4); CellRangeAddress copy = ref1.Copy(); Assert.AreEqual(ref1.ToString(), copy.ToString()); }