Ejemplo n.º 1
0
        private int GetIdFont(eStyleProperty styleProperty, object value)
        {
            ExcelFontXml fnt = Font.Copy();

            switch (styleProperty)
            {
            case eStyleProperty.Name:
                fnt.Name = value.ToString();
                break;

            case eStyleProperty.Size:
                fnt.Size = (float)value;
                break;

            case eStyleProperty.Family:
                fnt.Family = (int)value;
                break;

            case eStyleProperty.Bold:
                fnt.Bold = (bool)value;
                break;

            case eStyleProperty.Italic:
                fnt.Italic = (bool)value;
                break;

            case eStyleProperty.Strike:
                fnt.Strike = (bool)value;
                break;

            case eStyleProperty.UnderlineType:
                fnt.UnderLineType = (ExcelUnderLineType)value;
                break;

            case eStyleProperty.Color:
                fnt.Color.Rgb = value.ToString();
                break;

            case eStyleProperty.VerticalAlign:
                fnt.VerticalAlign = ((ExcelVerticalAlignmentFont)value) == ExcelVerticalAlignmentFont.None ? "" : value.ToString().ToLower();
                break;

            default:
                throw (new Exception("Invalid property for class Font"));
            }
            int    subId;
            string id = fnt.Id;

            subId = _styles.Fonts.FindIndexByID(id);
            if (subId == int.MinValue)
            {
                return(_styles.Fonts.Add(id, fnt));
            }
            return(subId);
        }
Ejemplo n.º 2
0
        internal ExcelFontXml Copy()
        {
            ExcelFontXml newFont = new ExcelFontXml(NameSpaceManager);

            newFont.Name          = Name;
            newFont.Size          = Size;
            newFont.Family        = Family;
            newFont.Scheme        = Scheme;
            newFont.Bold          = Bold;
            newFont.Italic        = Italic;
            newFont.UnderLineType = UnderLineType;
            newFont.Strike        = Strike;
            newFont.VerticalAlign = VerticalAlign;
            newFont.Color         = Color.Copy();
            return(newFont);
        }
Ejemplo n.º 3
0
 internal ExcelFontXml Copy()
 {
     ExcelFontXml newFont = new ExcelFontXml(NameSpaceManager);
     newFont.Name = Name;
     newFont.Size = Size;
     newFont.Family = Family;
     newFont.Scheme = Scheme;
     newFont.Bold = Bold;
     newFont.Italic = Italic;
     newFont.UnderLineType = UnderLineType;
     newFont.Strike = Strike;
     newFont.VerticalAlign = VerticalAlign;
     newFont.Color = Color.Copy();
     return newFont;
 }
Ejemplo 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;
                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);
                }
            }
        }