Esempio n. 1
0
        internal FontXmlWrapper Copy()
        {
            FontXmlWrapper newFont = new FontXmlWrapper();

            newFont.Name          = Name;
            newFont.Size          = Size;
            newFont.Family        = Family;
            newFont.Scheme        = Scheme;
            newFont.Bold          = Bold;
            newFont.Italic        = Italic;
            newFont.UnderLine     = UnderLine;
            newFont.Strike        = Strike;
            newFont.VerticalAlign = VerticalAlign;
            newFont.Color         = Color.Copy();

            return(newFont);
        }
Esempio n. 2
0
        private static XElement WriteFont(FontXmlWrapper font)
        {
            XElement fontXml = new XElement(ExcelCommon.Schema_WorkBook_Main + "font");

            if (font.Size > 0)
            {
                XElement szXml = new XElement(ExcelCommon.Schema_WorkBook_Main + "sz");
                szXml.Add(new XAttribute("val", font.Size.ToString(CultureInfo.InvariantCulture)));
                fontXml.Add(szXml);
            }

            if (font._Color != null)
                fontXml.Add(WriteColor(font._Color));

            fontXml.Add(new XElement(ExcelCommon.Schema_WorkBook_Main + "name",
                new XAttribute("val", font.Name.ToString(CultureInfo.InvariantCulture))));

            if (font.Family > int.MinValue)
                fontXml.Add(new XElement(ExcelCommon.Schema_WorkBook_Main + "family",
                    new XAttribute("val", font.Family.ToString(CultureInfo.InvariantCulture))));

            if (font.Scheme.IsNotEmpty())
                fontXml.Add(new XElement(ExcelCommon.Schema_WorkBook_Main + "scheme",
                    new XAttribute("val", font.Scheme.ToString(CultureInfo.InvariantCulture))));

            if (font.Bold)
                fontXml.Add(new XElement(ExcelCommon.Schema_WorkBook_Main + "b"));

            if (font.Italic)
                fontXml.Add(new XElement(ExcelCommon.Schema_WorkBook_Main + "i"));

            if (font.Strike)
                fontXml.Add(new XElement(ExcelCommon.Schema_WorkBook_Main + "strike"));

            if (font.UnderLine)
                fontXml.Add(new XElement(ExcelCommon.Schema_WorkBook_Main + "u"));

            if (font.VerticalAlign.IsNotEmpty())
                fontXml.Add(new XElement(ExcelCommon.Schema_WorkBook_Main + "vertAlign",
                    new XAttribute("val", font.VerticalAlign.ToString(CultureInfo.InvariantCulture))));

            return fontXml;
        }
Esempio n. 3
0
        /// <summary>
        /// FileName:styles.xml
        /// <para>NodePath:styleSheet/fonts</para>
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        public void ReadStyles_fonts(WorkBookStylesWrapper target, XElement item)
        {
            foreach (XElement fontElement in item.Nodes())
            {
                FontXmlWrapper fontObj = new FontXmlWrapper();
                foreach (XElement styleElement in fontElement.Nodes())
                {
                    switch (styleElement.Name.LocalName)
                    {
                        case "b":
                            {
                                fontObj.Bold = true;
                                break;
                            }
                        case "i":
                            {
                                fontObj.Italic = true;
                                break;
                            }
                        case "u":
                            {
                                fontObj.UnderLine = true;
                                break;
                            }
                        case "shadow":
                            {
                                fontObj.Shadow = true;
                                break;
                            }
                        case "vertAlign":
                            {
                                if (styleElement.Attribute("val") != null)
                                {
                                    fontObj.VerticalAlign = styleElement.Attribute("val").Value;
                                }
                                break;
                            }
                        case "sz":
                            {
                                if (styleElement.Attribute("val") != null)
                                {
                                    fontObj.Size = float.Parse(styleElement.Attribute("val").Value);
                                }
                                break;
                            }
                        case "color":
                            {
                                fontObj.Color = new ColorXmlWrapper();
                                this.ReadStyles_Color(styleElement, fontObj.Color);
                                break;
                            }
                        case "rFont":
                            {
                                // this._ = reader.GetAttribute("val");
                                break;
                            }
                        case "name":
                            {
                                if (styleElement.Attribute("val") != null)
                                {
                                    fontObj.Name = styleElement.Attribute("val").Value;
                                }
                                break;
                            }
                        case "family":
                            {
                                if (styleElement.Attribute("val") != null)
                                {
                                    fontObj.Family = int.Parse(styleElement.Attribute("val").Value);
                                }
                                break;
                            }
                        case "charset":
                            {
                                if (styleElement.Attribute("val") != null)
                                {
                                    fontObj.Charset = int.Parse(styleElement.Attribute("val").Value);
                                }
                                break;
                            }
                        case "scheme":
                            {
                                if (styleElement.Attribute("val") != null)
                                {
                                    fontObj.Scheme = styleElement.Attribute("val").Value;
                                }
                                break;
                            }
                    }
                }

                target.Fonts.Add(fontObj.Id, fontObj);
            }
        }
Esempio n. 4
0
        internal FontXmlWrapper Copy()
        {
            FontXmlWrapper newFont = new FontXmlWrapper();
            newFont.Name = Name;
            newFont.Size = Size;
            newFont.Family = Family;
            newFont.Scheme = Scheme;
            newFont.Bold = Bold;
            newFont.Italic = Italic;
            newFont.UnderLine = UnderLine;
            newFont.Strike = Strike;
            newFont.VerticalAlign = VerticalAlign;
            newFont.Color = Color.Copy();

            return newFont;
        }