Esempio n. 1
0
        private void SetAllNull()
        {
            Pane = new SLPane();

            Selections      = new List <SLSelection>();
            PivotSelections = new List <PivotSelection>();

            WindowProtection   = false;
            ShowFormulas       = false;
            ShowGridLines      = true;
            ShowRowColHeaders  = true;
            ShowZeros          = true;
            RightToLeft        = false;
            TabSelected        = false;
            ShowRuler          = true;
            ShowOutlineSymbols = true;
            DefaultGridColor   = true;
            ShowWhiteSpace     = true;
            View                      = SheetViewValues.Normal;
            TopLeftCell               = string.Empty;
            ColorId                   = 64;
            iZoomScale                = 100;
            iZoomScaleNormal          = 0;
            iZoomScaleSheetLayoutView = 0;
            iZoomScalePageLayoutView  = 0;
            WorkbookViewId            = 0;
        }
Esempio n. 2
0
        internal SLPane Clone()
        {
            var p = new SLPane();

            p.HorizontalSplit = HorizontalSplit;
            p.VerticalSplit   = VerticalSplit;
            p.TopLeftCell     = TopLeftCell;
            p.ActivePane      = ActivePane;
            p.State           = State;

            return(p);
        }
Esempio n. 3
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));
                    }
                }
            }
        }