Esempio n. 1
0
 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);
             }
         }
     }
 }