Xml access class xfs records. This is the top level style object.
Inheritance: OfficeOpenXml.Style.XmlAccess.StyleXmlHelper
Esempio n. 1
0
 internal ExcelXfs Copy(ExcelStyles styles)
 {
     ExcelXfs newXF = new ExcelXfs(NameSpaceManager, styles);
     newXF.NumberFormatId = _numFmtId;
     newXF.FontId = _fontId;
     newXF.FillId = _fillId;
     newXF.BorderId = _borderId;
     newXF.XfId = _xfID;
     newXF.ReadingOrder = _readingOrder;
     newXF.HorizontalAlignment = _horizontalAlignment;
     newXF.VerticalAlignment = _verticalAlignment;
     newXF.WrapText = _wrapText;
     newXF.ShrinkToFit = _shrinkToFit;
     newXF.Indent = _indent;
     newXF.TextRotation = _textRotation;
     newXF.Locked = _locked;
     newXF.Hidden = _hidden;
     return newXF;
 }
Esempio n. 2
0
        /// <summary>
        /// Loads the style XML to memory
        /// </summary>
        private void LoadFromDocument()
        {
            //NumberFormats
            ExcelNumberFormatXml.AddBuildIn(NameSpaceManager, NumberFormats);
            XmlNode numNode = _styleXml.SelectSingleNode(NumberFormatsPath, _nameSpaceManager);
            if (numNode != null)
            {
                foreach (XmlNode n in numNode)
                {
                    ExcelNumberFormatXml nf = new ExcelNumberFormatXml(_nameSpaceManager, n);
                    NumberFormats.Add(nf.Id, nf);
                    if (nf.NumFmtId >= NumberFormats.NextId) NumberFormats.NextId=nf.NumFmtId+1;
                }
            }

            //Fonts
            XmlNode fontNode = _styleXml.SelectSingleNode(FontsPath, _nameSpaceManager);
            foreach (XmlNode n in fontNode)
            {
                ExcelFontXml f = new ExcelFontXml(_nameSpaceManager, n);
                Fonts.Add(f.Id, f);
            }

            //Fills
            XmlNode fillNode = _styleXml.SelectSingleNode(FillsPath, _nameSpaceManager);
            foreach (XmlNode n in fillNode)
            {
                ExcelFillXml f;
                if (n.FirstChild != null && n.FirstChild.LocalName == "gradientFill")
                {
                    f = new ExcelGradientFillXml(_nameSpaceManager, n);
                }
                else
                {
                    f = new ExcelFillXml(_nameSpaceManager, n);
                }
                Fills.Add(f.Id, f);
            }

            //Borders
            XmlNode borderNode = _styleXml.SelectSingleNode(BordersPath, _nameSpaceManager);
            foreach (XmlNode n in borderNode)
            {
                ExcelBorderXml b = new ExcelBorderXml(_nameSpaceManager, n);
                Borders.Add(b.Id, b);
            }

            //cellStyleXfs
            XmlNode styleXfsNode = _styleXml.SelectSingleNode(CellStyleXfsPath, _nameSpaceManager);
            if (styleXfsNode != null)
            {
                foreach (XmlNode n in styleXfsNode)
                {
                    ExcelXfs item = new ExcelXfs(_nameSpaceManager, n, this);
                    CellStyleXfs.Add(item.Id, item);
                }
            }

            XmlNode styleNode = _styleXml.SelectSingleNode(CellXfsPath, _nameSpaceManager);
            for (int i = 0; i < styleNode.ChildNodes.Count; i++)
            {
                XmlNode n = styleNode.ChildNodes[i];
                ExcelXfs item = new ExcelXfs(_nameSpaceManager, n, this);
                CellXfs.Add(item.Id, item);
            }

            //cellStyle
            XmlNode namedStyleNode = _styleXml.SelectSingleNode(CellStylesPath, _nameSpaceManager);
            if (namedStyleNode != null)
            {
                foreach (XmlNode n in namedStyleNode)
                {
                    ExcelNamedStyleXml item = new ExcelNamedStyleXml(_nameSpaceManager, n, this);
                    NamedStyles.Add(item.Name, item);
                }
            }

            //dxfsPath
            XmlNode dxfsNode = _styleXml.SelectSingleNode(dxfsPath, _nameSpaceManager);
            if (dxfsNode != null)
            {
                foreach (XmlNode x in dxfsNode)
                {
                    ExcelDxfStyleConditionalFormatting item = new ExcelDxfStyleConditionalFormatting(_nameSpaceManager, x, this);
                    Dxfs.Add(item.Id, item);
                }
            }
        }
Esempio n. 3
0
 internal void RegisterEvent(ExcelXfs xf)
 {
     //                RegisterEvent(xf, xf.Xf_ChangedEvent);
 }
Esempio n. 4
0
        /// <summary>
        /// Loads the style XML to memory
        /// </summary>
        private void LoadFromDocument()
        {
            //NumberFormats
            ExcelNumberFormatXml.AddBuildIn(NameSpaceManager, NumberFormats);
            XmlNode numNode = _styleXml.SelectSingleNode(NumberFormatsPath, _nameSpaceManager);
            if (numNode != null)
            {
                foreach (XmlNode n in numNode)
                {
                    ExcelNumberFormatXml nf = new ExcelNumberFormatXml(_nameSpaceManager, n);
                    NumberFormats.Add(nf.Id, nf);
                    if (nf.NumFmtId >= NumberFormats.NextId) NumberFormats.NextId=nf.NumFmtId+1;
                }
            }

            //Fonts
            XmlNode fontNode = _styleXml.SelectSingleNode(FontsPath, _nameSpaceManager);
            foreach (XmlNode n in fontNode)
            {
                ExcelFontXml f = new ExcelFontXml(_nameSpaceManager, n);
                Fonts.Add(f.Id, f);
            }

            //Fills
            XmlNode fillNode = _styleXml.SelectSingleNode(FillsPath, _nameSpaceManager);
            foreach (XmlNode n in fillNode)
            {
                ExcelFillXml f = new ExcelFillXml(_nameSpaceManager, n);
                Fills.Add(f.Id, f);
            }

            //Borders
            XmlNode borderNode = _styleXml.SelectSingleNode(BordersPath, _nameSpaceManager);
            foreach (XmlNode n in borderNode)
            {
                ExcelBorderXml b = new ExcelBorderXml(_nameSpaceManager, n);
                Borders.Add(b.Id, b);
            }

            //cellStyleXfs
            XmlNode styleXfsNode = _styleXml.SelectSingleNode(CellStyleXfsPath, _nameSpaceManager);
            foreach (XmlNode n in styleXfsNode)
            {
                ExcelXfs item = new ExcelXfs(_nameSpaceManager, n, this);
                CellStyleXfs.Add(item.Id, item);
            }

            XmlNode styleNode = _styleXml.SelectSingleNode(CellXfsPath, _nameSpaceManager);
            for (int i = 0; i < styleNode.ChildNodes.Count; i++)
            {
                XmlNode n = styleNode.ChildNodes[i];
                ExcelXfs item = new ExcelXfs(_nameSpaceManager, n, this);
                CellXfs.Add(item.Id, item);
            }

            //cellStyle
            XmlNode namedStyleNode = _styleXml.SelectSingleNode(CellStylesPath, _nameSpaceManager);
            foreach (XmlNode n in namedStyleNode)
            {
                ExcelNamedStyleXml item = new ExcelNamedStyleXml(_nameSpaceManager, n, this);
                NamedStyles.Add(item.Name, item);
            }
        }
Esempio n. 5
0
 internal ExcelXfs Copy()
 {
     ExcelXfs newXF = new ExcelXfs(NameSpaceManager, _styles);
     newXF.NumberFormatId = _numFmtId;
     newXF.FontId = _fontId;
     newXF.FillId = _fillId;
     newXF.BorderId = _borderId;
     newXF.XfId = _xfID;
     newXF.ReadingOrder = _readingOrder;
     newXF.HorizontalAlignment = _horizontalAlignment;
     newXF.VerticalAlignment = _verticalAlignment;
     newXF.WrapText = _wrapText;
     return newXF;
 }
Esempio n. 6
0
 internal void RegisterEvent(ExcelXfs xf)
 {
     //                RegisterEvent(xf, xf.Xf_ChangedEvent);
 }
Esempio n. 7
0
        internal int GetNewID(ExcelStyleCollection <ExcelXfs> xfsCol, StyleBase styleObject, eStyleClass styleClass, eStyleProperty styleProperty, object value)
        {
            ExcelXfs newXfs = this.Copy();

            switch (styleClass)
            {
            case eStyleClass.Numberformat:
                newXfs.NumberFormatId = GetIdNumberFormat(styleProperty, value);
                styleObject.SetIndex(newXfs.NumberFormatId);
                break;

            case eStyleClass.Font:
            {
                newXfs.FontId = GetIdFont(styleProperty, value);
                styleObject.SetIndex(newXfs.FontId);
                break;
            }

            case eStyleClass.Fill:
            case eStyleClass.FillBackgroundColor:
            case eStyleClass.FillPatternColor:
                newXfs.FillId = GetIdFill(styleClass, styleProperty, value);
                styleObject.SetIndex(newXfs.FillId);
                break;

            case eStyleClass.GradientFill:
            case eStyleClass.FillGradientColor1:
            case eStyleClass.FillGradientColor2:
                newXfs.FillId = GetIdGradientFill(styleClass, styleProperty, value);
                styleObject.SetIndex(newXfs.FillId);
                break;

            case eStyleClass.Border:
            case eStyleClass.BorderBottom:
            case eStyleClass.BorderDiagonal:
            case eStyleClass.BorderLeft:
            case eStyleClass.BorderRight:
            case eStyleClass.BorderTop:
                newXfs.BorderId = GetIdBorder(styleClass, styleProperty, value);
                styleObject.SetIndex(newXfs.BorderId);
                break;

            case eStyleClass.Style:
                switch (styleProperty)
                {
                case eStyleProperty.XfId:
                    newXfs.XfId = (int)value;
                    break;

                case eStyleProperty.HorizontalAlign:
                    newXfs.HorizontalAlignment = (ExcelHorizontalAlignment)value;
                    break;

                case eStyleProperty.VerticalAlign:
                    newXfs.VerticalAlignment = (ExcelVerticalAlignment)value;
                    break;

                case eStyleProperty.WrapText:
                    newXfs.WrapText = (bool)value;
                    break;

                case eStyleProperty.ReadingOrder:
                    newXfs.ReadingOrder = (ExcelReadingOrder)value;
                    break;

                case eStyleProperty.ShrinkToFit:
                    newXfs.ShrinkToFit = (bool)value;
                    break;

                case eStyleProperty.Indent:
                    newXfs.Indent = (int)value;
                    break;

                case eStyleProperty.TextRotation:
                    newXfs.TextRotation = (int)value;
                    break;

                case eStyleProperty.Locked:
                    newXfs.Locked = (bool)value;
                    break;

                case eStyleProperty.Hidden:
                    newXfs.Hidden = (bool)value;
                    break;

                default:
                    throw (new Exception("Invalid property for class style."));
                }
                break;

            default:
                break;
            }
            int id = xfsCol.FindIndexByID(newXfs.Id);

            if (id < 0)
            {
                return(xfsCol.Add(newXfs.Id, newXfs));
            }
            return(id);
        }