public void SaveSparkline(int row, int column, SparklineInfo sparkline) { if (sparkline != null) { _sparklines.Add(new CellData(row, column, sparkline)); } _sparklineSaved = true; }
public static void UndoCellsInfo(Worksheet sheet, CopyMoveCellsInfo cellsInfo, int baseRow, int baseColumn, SheetArea area) { int rowCount = cellsInfo.RowCount; int columnCount = cellsInfo.ColumnCount; sheet.SuspendCalcService(); try { for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { if (cellsInfo.IsFormulaSaved() && (area == SheetArea.Cells)) { sheet.SetFormula(baseRow + i, baseColumn + j, null); } if (cellsInfo.IsSparklineSaved() && (area == SheetArea.Cells)) { sheet.RemoveSparkline(baseRow + i, baseColumn + j); } if (cellsInfo.IsValueSaved()) { sheet.SetValue(baseRow + i, baseColumn + j, area, null); } if (cellsInfo.IsStyleSaved()) { SetStyleObject(sheet, baseRow + i, baseColumn + j, area, null); } if (cellsInfo.IsTagSaved()) { sheet.SetTag(baseRow + i, baseColumn + j, area, null); } } } if (cellsInfo.IsFormulaSaved() && (area == SheetArea.Cells)) { foreach (CellData data in cellsInfo.GetFormulas()) { sheet.SetFormula(baseRow + data.Row, baseColumn + data.Column, (string)(data.Value as string)); } } if (cellsInfo.IsSparklineSaved() && (area == SheetArea.Cells)) { foreach (CellData data2 in cellsInfo.GetSparklines()) { SparklineInfo info = data2.Value as SparklineInfo; if (info == null) { ((ISparklineSheet)sheet).SetSparkline(baseRow + data2.Row, baseColumn + data2.Column, null); } else if (info.DataAxisRange == null) { sheet.SetSparkline(baseRow + data2.Row, baseColumn + data2.Column, info.DataRange, info.Sparkline.DataOrientation, info.Sparkline.SparklineType, info.Sparkline.Setting); } else { sheet.SetSparkline(baseRow + data2.Row, baseColumn + data2.Column, info.DataRange, info.Sparkline.DataOrientation, info.Sparkline.SparklineType, info.DataAxisRange, info.Sparkline.DateAxisOrientation, info.Sparkline.Setting); } } } if (cellsInfo.IsValueSaved()) { foreach (CellData data3 in cellsInfo.GetValues()) { sheet.SetValue(baseRow + data3.Row, baseColumn + data3.Column, area, data3.Value); } } if (cellsInfo.IsStyleSaved()) { foreach (CellData data4 in cellsInfo.GetStyles()) { SetStyleObject(sheet, baseRow + data4.Row, baseColumn + data4.Column, area, data4.Value); } } if (cellsInfo.IsTagSaved()) { foreach (CellData data5 in cellsInfo.GetTags()) { sheet.SetTag(baseRow + data5.Row, baseColumn + data5.Column, area, data5.Value); } } if (cellsInfo.IsArrayFormulaSaved() && (area == SheetArea.Cells)) { object[,] arrayFormula = Excel.GetsArrayFormulas(sheet, baseRow, baseColumn, rowCount, columnCount); if ((arrayFormula != null) && (arrayFormula.Length > 0)) { int length = arrayFormula.GetLength(0); for (int k = 0; k < length; k++) { CellRange range = (CellRange)arrayFormula[k, 0]; sheet.SetArrayFormula(range.Row, range.Column, range.RowCount, range.ColumnCount, null); } } arrayFormula = cellsInfo.GetArrayFormula(); if ((arrayFormula != null) && (arrayFormula.Length > 0)) { int num7 = arrayFormula.GetLength(0); for (int m = 0; m < num7; m++) { CellRange range2 = (CellRange)arrayFormula[m, 0]; string formula = (string)((string)arrayFormula[m, 1]); if (formula.StartsWith("{") && formula.EndsWith("}")) { formula = formula.Substring(1, formula.Length - 2); } sheet.SetArrayFormula(range2.Row, range2.Column, range2.RowCount, range2.ColumnCount, formula); } } } } finally { sheet.ResumeCalcService(); } SheetSpanModel spanModel = null; if (area == SheetArea.Cells) { spanModel = sheet.SpanModel; } else if (area == SheetArea.ColumnHeader) { spanModel = sheet.ColumnHeaderSpanModel; } else if (area == (SheetArea.CornerHeader | SheetArea.RowHeader)) { spanModel = sheet.RowHeaderSpanModel; } if ((spanModel != null) && !spanModel.IsEmpty()) { List <CellRange> list6 = new List <CellRange>(); IEnumerator enumerator = spanModel.GetEnumerator(baseRow, baseColumn, rowCount, columnCount); while (enumerator.MoveNext()) { CellRange current = enumerator.Current as CellRange; if (current != null) { list6.Add(current); } } foreach (CellRange range4 in list6) { spanModel.Remove(range4.Row, range4.Column); } } if (cellsInfo.IsSpanSaved() && (spanModel != null)) { foreach (CellRange range5 in cellsInfo.Spans) { spanModel.Add(range5.Row, range5.Column, range5.RowCount, range5.ColumnCount); } } }