private void WriteComments_comment_text_rPr(XElement textNode, RichText rt) { XElement rtnode = new XElement(XName.Get("rPr", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); XElement rPrNode = null; if (rt.Bold) { XElement b = new XElement(XName.Get("b", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); rtnode.Add(b); } if (rt._Charset != int.MinValue) { rPrNode = new XElement(XName.Get("charset", ExcelCommon.Schema_WorkBook_Main.NamespaceName), new XAttribute("val", rt._Charset)); rtnode.Add(rPrNode); } if (rt._DataBarColor != null) { rPrNode = WriteColor(rt._DataBarColor); if (rPrNode != null) { rtnode.Add(rPrNode); } } if (rt.Condense) { rPrNode = new XElement(XName.Get("condense", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); rtnode.Add(rPrNode); } if (rt.Extend) { rPrNode = new XElement(XName.Get("extend", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); rtnode.Add(rPrNode); } //todo: family if (rt.Italic) { rPrNode = new XElement(XName.Get("i", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); rtnode.Add(rPrNode); } if (rt.Outline) { rPrNode = new XElement(XName.Get("outline", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); rtnode.Add(rPrNode); } if (rt.FontName.IsNotEmpty()) { rPrNode = new XElement(XName.Get("rFont", ExcelCommon.Schema_WorkBook_Main.NamespaceName), new XAttribute("val", rt.FontName)); rtnode.Add(rPrNode); } if (rt.Scheme.IsNotEmpty()) { rPrNode = new XElement(XName.Get("scheme", ExcelCommon.Schema_WorkBook_Main.NamespaceName), new XAttribute("val", rt.Scheme)); rtnode.Add(rPrNode); } if (rt.Shadow) { rPrNode = new XElement(XName.Get("shadow", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); rtnode.Add(rPrNode); } if (rt.Strike) { rPrNode = new XElement(XName.Get("strike", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); rtnode.Add(rPrNode); } if (rt.Size != int.MinValue) { rPrNode = new XElement(XName.Get("sz", ExcelCommon.Schema_WorkBook_Main.NamespaceName), new XAttribute("val", rt.Size)); rtnode.Add(rPrNode); } if (rt.UnderLine) { rPrNode = new XElement(XName.Get("u", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); rtnode.Add(rPrNode); } if (rt.VerticalAlign != ExcelVerticalAlignmentFont.None) { rPrNode = new XElement(XName.Get("vertAlign", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); rPrNode.Add(new XAttribute("val", rt.VerticalAlign.ToString().ToLower())); rtnode.Add(rPrNode); } textNode.Add(rtnode); }
internal void ReadSheetComments_Comment(List<string> authors, XElement commentMode, Comment cellComment) { if (commentMode.Attribute("authorId") != null) { cellComment.Author = authors[int.Parse(commentMode.Attribute("authorId").Value)]; } XElement textPropertyNode = commentMode.Element(XName.Get("text", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (textPropertyNode != null) { IEnumerable<XElement> richTextNodes = textPropertyNode.Elements(XName.Get("r", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); foreach (XElement richtextNode in richTextNodes) { RichText rt = new RichText(); XElement rtnode = richtextNode.Element(XName.Get("t", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rtnode != null) { if (rtnode.Attribute(XName.Get("space", ExcelCommon.Schema_Xml)) != null) { rt.PreserveSpace = true; } rt.Text = rtnode.Value; } rtnode = richtextNode.Element(XName.Get("rPr", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rtnode != null) { XElement rPrNode = rtnode.Element(XName.Get("b", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { rt.Bold = true; } rPrNode = rtnode.Element(XName.Get("charset", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { if (rPrNode.Attribute(XName.Get("val", ExcelCommon.Schema_WorkBook_Main.NamespaceName)) != null) { rt.Charset = int.Parse(rPrNode.Attribute(XName.Get("val", ExcelCommon.Schema_WorkBook_Main.NamespaceName)).Value); } } rPrNode = rtnode.Element(XName.Get("color", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { ColorXmlWrapper rtColor = new ColorXmlWrapper(); ReadStyles_Color(rPrNode, rtColor); rt._DataBarColor = rtColor; } rPrNode = rtnode.Element(XName.Get("condense", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { rt.Condense = true; } rPrNode = rtnode.Element(XName.Get("extend", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { rt.Extend = true; } //todo: family //rPrNode = richtextNode.Element(XName.Get("family", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); //if (rPrNode != null) //{ // if (rPrNode.Attribute(XName.Get("val", ExcelCommon.Schema_WorkBook_Main.NamespaceName)) != null) // { // rt.FontName = rPrNode.Attribute(XName.Get("val", ExcelCommon.Schema_WorkBook_Main.NamespaceName)).Value; // } //} rPrNode = rtnode.Element(XName.Get("i", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { rt.Italic = true; } rPrNode = rtnode.Element(XName.Get("outline", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { rt.Outline = true; } rPrNode = rtnode.Element(ExcelCommon.Schema_WorkBook_Main + "rFont"); if (rPrNode != null) { if (rPrNode.Attribute("val") != null) { rt.FontName = rPrNode.Attribute("val").Value; } } rPrNode = rtnode.Element(XName.Get("scheme", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { if (rPrNode.Attribute("val") != null) { rt.Scheme = rPrNode.Attribute("val").Value; } } rPrNode = rtnode.Element(XName.Get("shadow", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { rt.Shadow = true; } rPrNode = rtnode.Element(XName.Get("strike", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { rt.Strike = true; } rPrNode = rtnode.Element(XName.Get("sz", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { if (rPrNode.Attribute("val") != null) { rt.Size = float.Parse(rPrNode.Attribute("val").Value); } } rPrNode = rtnode.Element(XName.Get("u", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { rt.UnderLine = true; } rPrNode = rtnode.Element(XName.Get("vertAlign", ExcelCommon.Schema_WorkBook_Main.NamespaceName)); if (rPrNode != null) { if (rPrNode.Attribute("val") != null) { rt.VerticalAlign = (ExcelVerticalAlignmentFont)Enum.Parse(typeof(ExcelVerticalAlignmentFont), rPrNode.Attribute("val").Value, true); ; } } } cellComment.RichText.Add(rt); } } }