internal SLSelection Clone()
        {
            var s = new SLSelection();

            s.Pane         = Pane;
            s.ActiveCell   = ActiveCell;
            s.ActiveCellId = ActiveCellId;

            s.SequenceOfReferences = new List <SLCellPointRange>();
            foreach (var pt in SequenceOfReferences)
            {
                s.SequenceOfReferences.Add(new SLCellPointRange(pt.StartRowIndex, pt.StartColumnIndex, pt.EndRowIndex,
                                                                pt.EndColumnIndex));
            }

            return(s);
        }
示例#2
0
        internal void FromSheetView(SheetView sv)
        {
            SetAllNull();

            if (sv.WindowProtection != null)
            {
                WindowProtection = sv.WindowProtection.Value;
            }
            if (sv.ShowFormulas != null)
            {
                ShowFormulas = sv.ShowFormulas.Value;
            }
            if (sv.ShowGridLines != null)
            {
                ShowGridLines = sv.ShowGridLines.Value;
            }
            if (sv.ShowRowColHeaders != null)
            {
                ShowRowColHeaders = sv.ShowRowColHeaders.Value;
            }
            if (sv.ShowZeros != null)
            {
                ShowZeros = sv.ShowZeros.Value;
            }
            if (sv.RightToLeft != null)
            {
                RightToLeft = sv.RightToLeft.Value;
            }
            if (sv.TabSelected != null)
            {
                TabSelected = sv.TabSelected.Value;
            }
            if (sv.ShowRuler != null)
            {
                ShowRuler = sv.ShowRuler.Value;
            }
            if (sv.ShowOutlineSymbols != null)
            {
                ShowOutlineSymbols = sv.ShowOutlineSymbols.Value;
            }
            if (sv.DefaultGridColor != null)
            {
                DefaultGridColor = sv.DefaultGridColor.Value;
            }
            if (sv.ShowWhiteSpace != null)
            {
                ShowWhiteSpace = sv.ShowWhiteSpace.Value;
            }
            if (sv.View != null)
            {
                View = sv.View.Value;
            }
            if (sv.TopLeftCell != null)
            {
                TopLeftCell = sv.TopLeftCell.Value;
            }
            if (sv.ColorId != null)
            {
                ColorId = sv.ColorId.Value;
            }
            if (sv.ZoomScale != null)
            {
                ZoomScale = sv.ZoomScale.Value;
            }
            if (sv.ZoomScaleNormal != null)
            {
                ZoomScaleNormal = sv.ZoomScaleNormal.Value;
            }
            if (sv.ZoomScaleSheetLayoutView != null)
            {
                ZoomScaleSheetLayoutView = sv.ZoomScaleSheetLayoutView.Value;
            }
            if (sv.ZoomScalePageLayoutView != null)
            {
                ZoomScalePageLayoutView = sv.ZoomScalePageLayoutView.Value;
            }

            // required attribute but we'll use 0 as the default in case something terrible happens.
            if (sv.WorkbookViewId != null)
            {
                WorkbookViewId = sv.WorkbookViewId.Value;
            }
            else
            {
                WorkbookViewId = 0;
            }

            using (var oxr = OpenXmlReader.Create(sv))
            {
                SLSelection sel;
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Pane))
                    {
                        Pane = new SLPane();
                        Pane.FromPane((Pane)oxr.LoadCurrentElement());
                    }
                    else if (oxr.ElementType == typeof(Selection))
                    {
                        sel = new SLSelection();
                        sel.FromSelection((Selection)oxr.LoadCurrentElement());
                        Selections.Add(sel);
                    }
                    else if (oxr.ElementType == typeof(PivotSelection))
                    {
                        PivotSelections.Add((PivotSelection)oxr.LoadCurrentElement().CloneNode(true));
                    }
                }
            }
        }