public static void SaveViewportInfo(Worksheet sheet, CopyMoveCellsInfo cellsInfo, int baseRow, int baseColumn, CopyToOption option) { if ((option & CopyToOption.All) > ((CopyToOption)0)) { int rowCount = cellsInfo.RowCount; int columnCount = cellsInfo.ColumnCount; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { if ((option & CopyToOption.Value) > ((CopyToOption)0)) { cellsInfo.SaveValue(i, j, sheet.GetValue(baseRow + i, baseColumn + j, SheetArea.Cells)); } if (((option & CopyToOption.Value) > ((CopyToOption)0)) || ((option & CopyToOption.Formula) > ((CopyToOption)0))) { cellsInfo.SaveFormula(i, j, sheet.GetFormula(baseRow + i, baseColumn + j)); object[,] arrayFormulas = Excel.GetsArrayFormulas(sheet, baseRow, baseColumn, rowCount, columnCount); cellsInfo.SaveArrayFormula(arrayFormulas); } if ((option & CopyToOption.Sparkline) > ((CopyToOption)0)) { Sparkline sparkline = sheet.GetSparkline(baseRow + i, baseColumn + j); CellRange sparklineDataRange = sheet.Cells[baseRow + i, baseColumn + j].SparklineDataRange; CellRange sparklineDateAxisRange = sheet.Cells[baseRow + i, baseColumn + j].SparklineDateAxisRange; if ((sparkline != null) && (sparklineDataRange != null)) { cellsInfo.SaveSparkline(i, j, new SparklineInfo(sparkline, sparklineDataRange, sparklineDateAxisRange)); } else { cellsInfo.SaveSparkline(i, j, null); } } if ((option & CopyToOption.Style) > ((CopyToOption)0)) { cellsInfo.SaveStyle(i, j, GetStyleObject(sheet, baseRow + i, baseColumn + j, SheetArea.Cells)); } if ((option & CopyToOption.Tag) > ((CopyToOption)0)) { cellsInfo.SaveTag(i, j, sheet.GetTag(baseRow + i, baseColumn + j, SheetArea.Cells)); } } } if ((option & CopyToOption.Span) > ((CopyToOption)0)) { IEnumerator enumerator = sheet.SpanModel.GetEnumerator(baseRow, baseColumn, rowCount, columnCount); while (enumerator.MoveNext()) { cellsInfo.SaveSpan((CellRange)enumerator.Current); } } } }
public static void SaveRowHeaderInfo(Worksheet sheet, CopyMoveCellsInfo headerCellsInfo, CopyMoveRowsInfo rowsInfo, int baseRow, CopyToOption option) { if ((option & CopyToOption.All) > ((CopyToOption)0)) { int rowCount = headerCellsInfo.RowCount; int columnCount = headerCellsInfo.ColumnCount; for (int i = 0; i < rowCount; i++) { for (int k = 0; k < columnCount; k++) { if ((option & CopyToOption.Value) > ((CopyToOption)0)) { headerCellsInfo.SaveValue(i, k, sheet.GetValue(baseRow + i, k, SheetArea.CornerHeader | SheetArea.RowHeader)); } if ((option & CopyToOption.Style) > ((CopyToOption)0)) { headerCellsInfo.SaveStyle(i, k, GetStyleObject(sheet, baseRow + i, k, SheetArea.CornerHeader | SheetArea.RowHeader)); } if ((option & CopyToOption.Tag) > ((CopyToOption)0)) { headerCellsInfo.SaveTag(i, k, sheet.GetTag(baseRow + i, k, SheetArea.CornerHeader | SheetArea.RowHeader)); } } } if ((option & CopyToOption.Span) > ((CopyToOption)0)) { IEnumerator enumerator = sheet.RowHeaderSpanModel.GetEnumerator(baseRow, 0, rowCount, columnCount); while (enumerator.MoveNext()) { headerCellsInfo.SaveSpan((CellRange)enumerator.Current); } } rowCount = rowsInfo.RowCount; for (int j = 0; j < rowCount; j++) { rowsInfo.SaveHeight(j, sheet.GetRowHeight(baseRow + j)); rowsInfo.SaveVisible(j, sheet.GetRowVisible(baseRow + j)); rowsInfo.SaveResizable(j, sheet.GetRowResizable(baseRow + j)); rowsInfo.SaveTag(j, sheet.GetTag(baseRow + j, -1)); } if ((option & CopyToOption.Style) > ((CopyToOption)0)) { for (int m = 0; m < rowCount; m++) { rowsInfo.SaveViewportRowStyle(m, GetStyleObject(sheet, baseRow + m, -1, SheetArea.Cells)); rowsInfo.SaveHeaderRowStyle(m, GetStyleObject(sheet, baseRow + m, -1, SheetArea.CornerHeader | SheetArea.RowHeader)); } } if ((option & CopyToOption.RangeGroup) > ((CopyToOption)0)) { RangeGroup rowRangeGroup = sheet.RowRangeGroup; if ((rowRangeGroup != null) && !rowRangeGroup.IsEmpty()) { for (int n = 0; n < rowCount; n++) { rowsInfo.SaveRangeGroup(n, rowRangeGroup.Data.GetLevel(baseRow + n), rowRangeGroup.Data.GetCollapsed(baseRow + n)); } } } } }
public static void SaveColumnHeaderInfo(Worksheet sheet, CopyMoveCellsInfo headerCellsInfo, CopyMoveColumnsInfo columnsInfo, int baseColumn, CopyToOption option) { int rowCount = headerCellsInfo.RowCount; int columnCount = headerCellsInfo.ColumnCount; for (int i = 0; i < rowCount; i++) { for (int k = 0; k < columnCount; k++) { if ((option & CopyToOption.Value) > ((CopyToOption)0)) { headerCellsInfo.SaveValue(i, k, sheet.GetValue(i, baseColumn + k, SheetArea.ColumnHeader)); } if ((option & CopyToOption.Style) > ((CopyToOption)0)) { headerCellsInfo.SaveStyle(i, k, GetStyleObject(sheet, i, baseColumn + k, SheetArea.ColumnHeader)); } if ((option & CopyToOption.Tag) > ((CopyToOption)0)) { headerCellsInfo.SaveTag(i, k, sheet.GetTag(i, baseColumn + k, SheetArea.ColumnHeader)); } } } if ((option & CopyToOption.Value) > ((CopyToOption)0)) { for (int m = 0; m < columnCount; m++) { if (sheet.IsColumnBound(baseColumn + m)) { columnsInfo.SaveBindingField(m, sheet.GetDataColumnName(baseColumn + m)); } } } if ((option & CopyToOption.Span) > ((CopyToOption)0)) { IEnumerator enumerator = sheet.ColumnHeaderSpanModel.GetEnumerator(0, baseColumn, rowCount, columnCount); while (enumerator.MoveNext()) { headerCellsInfo.SaveSpan((CellRange)enumerator.Current); } } columnCount = columnsInfo.ColumnCount; for (int j = 0; j < columnCount; j++) { columnsInfo.SaveWidth(j, sheet.GetColumnWidth(baseColumn + j)); columnsInfo.SaveVisible(j, sheet.GetColumnVisible(baseColumn + j)); columnsInfo.SaveResizable(j, sheet.GetColumnResizable(baseColumn + j)); columnsInfo.SaveTag(j, sheet.GetTag(-1, baseColumn + j)); } if ((option & CopyToOption.Style) > ((CopyToOption)0)) { for (int n = 0; n < columnCount; n++) { columnsInfo.SaveViewportColumnStyle(n, GetStyleObject(sheet, -1, baseColumn + n, SheetArea.Cells)); columnsInfo.SaveHeaderColumnStyle(n, GetStyleObject(sheet, -1, baseColumn + n, SheetArea.ColumnHeader)); } } if ((option & CopyToOption.RangeGroup) > ((CopyToOption)0)) { RangeGroup columnRangeGroup = sheet.ColumnRangeGroup; if ((columnRangeGroup != null) && !columnRangeGroup.IsEmpty()) { for (int num8 = 0; num8 < columnCount; num8++) { columnsInfo.SaveRangeGroup(num8, columnRangeGroup.Data.GetLevel(baseColumn + num8), columnRangeGroup.Data.GetCollapsed(baseColumn + num8)); } } } }