void MoveDataRange(int fromRow, int fromColumn, int toRow, int toColumn, int rowCount, int columnCount) { CellRange range = new CellRange(fromRow, fromColumn, rowCount, columnCount); int row = toRow - fromRow; int column = toColumn - fromColumn; using (List <SparklineGroup> .Enumerator enumerator = this.Groups.GetEnumerator()) { while (enumerator.MoveNext()) { foreach (Sparkline sparkline in enumerator.Current) { if (sparkline != null) { CalcExpression dateAxisReference = sparkline.DateAxisReference; CellRange expressionRange = GetExpressionRange(dateAxisReference); if (((expressionRange != null) && SameSource((ICalcSource)this.Sheet, dateAxisReference)) && (range.Contains(expressionRange) && range.Contains(sparkline.Row, sparkline.Column))) { sparkline.DateAxisReference = dateAxisReference.Offset(row, column, false, true); } CalcExpression dataReference = sparkline.DataReference; CellRange range3 = GetExpressionRange(dataReference); if (((range3 != null) && SameSource(this.Sheet as ICalcSource, dataReference)) && (range.Contains(range3) && range.Contains(sparkline.Row, sparkline.Column))) { sparkline.DataReference = dataReference.Offset(row, column, false, true); } } } } } }
public void Copy(Worksheet src, int fromRow, int fromColumn, int toRow, int toColumn, int rowCount, int columnCount) { if (object.ReferenceEquals(src, this.Sheet)) { this.Copy(fromRow, fromColumn, toRow, toColumn, rowCount, columnCount); } else { int offsetRow = toRow - fromRow; int offsetColumn = toColumn - fromColumn; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { Sparkline sparkline = src.GetSparkline(fromRow + i, fromColumn + j); if (sparkline != null) { Sparkline sparkline2 = sparkline.Clone(); sparkline2.Row = toRow + i; sparkline2.Column = toColumn + j; CalcExpression dateAxisReference = sparkline2.DateAxisReference; if (dateAxisReference != null) { if (CanOffset(dateAxisReference, offsetRow, offsetColumn, ((Worksheet)this.Sheet).RowCount, ((Worksheet)this.Sheet).ColumnCount)) { sparkline2.DateAxisReference = dateAxisReference.Offset(offsetRow, offsetColumn, false, true); } else { sparkline2.DateAxisReference = new CalcErrorExpression(CalcErrors.Reference); } } CalcExpression dataReference = sparkline2.DataReference; if (dataReference != null) { if (CanOffset(dataReference, offsetRow, offsetColumn, ((Worksheet)this.Sheet).RowCount, ((Worksheet)this.Sheet).ColumnCount)) { sparkline2.DataReference = dataReference.Offset(offsetRow, offsetColumn, false, true); } else { sparkline2.DataReference = new CalcErrorExpression(CalcErrors.Reference); } } this.Add(sparkline2.Group); this.Sheet.SetSparkline(toRow + i, toColumn + j, sparkline2); } else { this.Sheet.SetSparkline(toRow + i, toColumn + j, null); } } } } }
public void Copy(int fromRow, int fromColumn, int toRow, int toColumn, int rowCount, int columnCount) { DataMatrix <Sparkline> matrix = new DataMatrix <Sparkline>(rowCount, columnCount); int offsetRow = toRow - fromRow; int offsetColumn = toColumn - fromColumn; for (int i = 0; i < rowCount; i++) { for (int k = 0; k < columnCount; k++) { Sparkline sparkline = this.Sheet.GetSparkline(fromRow + i, fromColumn + k); if (sparkline != null) { Sparkline sparkline2 = sparkline.Clone(); sparkline2.Row = toRow + i; sparkline2.Column = toColumn + k; CalcExpression dateAxisReference = sparkline2.DateAxisReference; if (dateAxisReference != null) { if (CanOffset(dateAxisReference, offsetRow, offsetColumn, ((Worksheet)this.Sheet).RowCount, ((Worksheet)this.Sheet).ColumnCount)) { sparkline2.DateAxisReference = dateAxisReference.Offset(offsetRow, offsetColumn, false, true); } else { sparkline2.DateAxisReference = new CalcErrorExpression(CalcErrors.Reference); } } CalcExpression dataReference = sparkline2.DataReference; if (dataReference != null) { if (CanOffset(dataReference, offsetRow, offsetColumn, ((Worksheet)this.Sheet).RowCount, ((Worksheet)this.Sheet).ColumnCount)) { sparkline2.DataReference = dataReference.Offset(offsetRow, offsetColumn, false, true); } else { sparkline2.DataReference = new CalcErrorExpression(CalcErrors.Reference); } } this.Add(sparkline2.Group); matrix.SetValue(i, k, sparkline2); } } } for (int j = 0; j < rowCount; j++) { for (int m = 0; m < columnCount; m++) { this.Sheet.SetSparkline(toRow + j, toColumn + m, matrix.GetValue(j, m)); } } }