Пример #1
0
 public static object GetFormatValue(CellFormatType type, string value)
 {
     if (type.Equals(CellFormatType.None))
     {
         int    iVal;
         double dVal;
         if (int.TryParse(value, out iVal))
         {
             return(iVal);
         }
         else if (double.TryParse(value, out dVal))
         {
             return(dVal);
         }
     }
     else if (type.Equals(CellFormatType.IntPercent) || type.Equals(CellFormatType.FloatPercent))
     {
         double d = 0;
         if (double.TryParse(value.TrimEnd('%'), out d))
         {
             return(d / 100);
         }
     }
     return(value);
 }
Пример #2
0
        public RTCell(XmlNode parent)
        {
            XmlElement ele = (XmlElement)parent;

            if (ele.HasAttribute("value"))
            {
                this.value = parent.Attributes["value"].Value;
            }
            if (parent.HasChildNodes && this.value == null)
            {
                value = parent.FirstChild.Value;
            }

            if (ele.HasAttribute("format"))
            {
                this.cellFormatType   = (CellFormatType)int.Parse(parent.Attributes["format"].Value);
                this.cellFormatString = CellFormat.GetFormatString(this.cellFormatType);
            }
            if (ele.HasAttribute("bgcolor"))
            {
                try
                {
                    this.backgroundColorString = parent.Attributes["bgcolor"].Value.TrimStart('#');
                    this.backgroundColor       = ColorTranslator.FromHtml("#" + this.backgroundColorString);
                }
                catch {
                    this.backgroundColorString = null;
                }
            }
        }
Пример #3
0
        public static string GetFormatString(CellFormatType type)
        {
            switch (type)
            {
            case CellFormatType.IntPercent:
                return("##0%");

            case CellFormatType.FloatPercent:
                return("##0.0##%");
            }
            return(null);
        }
Пример #4
0
 public CellFormat(CellFormatType type, string fmt)
 {
     formatType = type;
     formatString = fmt;
 }
Пример #5
0
 public CellFormat(CellFormatType type, string fmt)
 {
     this.formatType   = type;
     this.formatString = fmt;
 }
Пример #6
0
 public CellFormat(CellFormatType type, string fmt)
 {
     formatType   = type;
     formatString = fmt;
 }