internal static void AddBuildIn(XmlNamespaceManager NameSpaceManager, ExcelStyleCollection <ExcelNumberFormatXml> NumberFormats)
        {
            NumberFormats.Add("General", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 0, Format = "General"
            });
            NumberFormats.Add("0", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 1, Format = "0"
            });
            NumberFormats.Add("0.00", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 2, Format = "0.00"
            });
            NumberFormats.Add("#,##0", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 3, Format = "#,##0"
            });
            NumberFormats.Add("#,##0.00", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 4, Format = "#,##0.00"
            });
            NumberFormats.Add("0%", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 9, Format = "0%"
            });
            NumberFormats.Add("0.00%", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 10, Format = "0.00%"
            });
            NumberFormats.Add("0.00E+00", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 11, Format = "0.00E+00"
            });
            NumberFormats.Add("# ?/?", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 12, Format = "# ?/?"
            });
            NumberFormats.Add("# ??/??", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 13, Format = "# ??/??"
            });
            NumberFormats.Add("mm-dd-yy", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 14, Format = "mm-dd-yy"
            });
            NumberFormats.Add("d-mmm-yy", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 15, Format = "d-mmm-yy"
            });
            NumberFormats.Add("d-mmm", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 16, Format = "d-mmm"
            });
            NumberFormats.Add("mmm-yy", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 17, Format = "mmm-yy"
            });
            NumberFormats.Add("h:mm AM/PM", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 18, Format = "h:mm AM/PM"
            });
            NumberFormats.Add("h:mm:ss AM/PM", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 19, Format = "h:mm:ss AM/PM"
            });
            NumberFormats.Add("h:mm", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 20, Format = "h:mm"
            });
            NumberFormats.Add("h:mm:ss", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 21, Format = "h:mm:ss"
            });
            NumberFormats.Add("m/d/yy h:mm", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 22, Format = "m/d/yy h:mm"
            });
            NumberFormats.Add("#,##0 ;(#,##0)", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 37, Format = "#,##0 ;(#,##0)"
            });
            NumberFormats.Add("#,##0 ;[Red](#,##0)", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 38, Format = "#,##0 ;[Red](#,##0)"
            });
            NumberFormats.Add("#,##0.00;(#,##0.00)", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 39, Format = "#,##0.00;(#,##0.00)"
            });
            NumberFormats.Add("#,##0.00;[Red](#,##0.00)", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 40, Format = "#,##0.00;[Red](#,#)"
            });
            NumberFormats.Add("mm:ss", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 45, Format = "mm:ss"
            });
            NumberFormats.Add("[h]:mm:ss", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 46, Format = "[h]:mm:ss"
            });
            NumberFormats.Add("mmss.0", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 47, Format = "mmss.0"
            });
            NumberFormats.Add("##0.0", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 48, Format = "##0.0"
            });
            NumberFormats.Add("@", new ExcelNumberFormatXml(NameSpaceManager, true)
            {
                NumFmtId = 49, Format = "@"
            });

            NumberFormats.NextId = 164; //Start for custom formats.
        }
Esempio n. 2
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);
        }
Esempio n. 3
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;
        }
        internal static void AddBuildIn(XmlNamespaceManager NameSpaceManager, ExcelStyleCollection<ExcelNumberFormatXml> NumberFormats)
        {
            NumberFormats.Add("General",new ExcelNumberFormatXml(NameSpaceManager,true){NumFmtId=0,Format="General"});
            NumberFormats.Add("0", new ExcelNumberFormatXml(NameSpaceManager,true) { NumFmtId = 1, Format = "0" });
            NumberFormats.Add("0.00", new ExcelNumberFormatXml(NameSpaceManager,true) { NumFmtId = 2, Format = "0.00" });
            NumberFormats.Add("#,##0", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 3, Format = "#,##0" });
            NumberFormats.Add("#,##0.00", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 4, Format = "#,##0.00" });
            NumberFormats.Add("0%", new ExcelNumberFormatXml(NameSpaceManager,true) { NumFmtId = 9, Format = "0%" });
            NumberFormats.Add("0.00%", new ExcelNumberFormatXml(NameSpaceManager,true) { NumFmtId = 10, Format = "0.00%" });
            NumberFormats.Add("0.00E+00", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 11, Format = "0.00E+00" });
            NumberFormats.Add("# ?/?", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 12, Format = "# ?/?" });
            NumberFormats.Add("# ??/??", new ExcelNumberFormatXml(NameSpaceManager,true) { NumFmtId = 13, Format = "# ??/??" });
            NumberFormats.Add("mm-dd-yy", new ExcelNumberFormatXml(NameSpaceManager,true) { NumFmtId = 14, Format = "mm-dd-yy" });
            NumberFormats.Add("d-mmm-yy", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 15, Format = "d-mmm-yy" });
            NumberFormats.Add("d-mmm", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 16, Format = "d-mmm" });
            NumberFormats.Add("mmm-yy", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 17, Format = "mmm-yy" });
            NumberFormats.Add("h:mm AM/PM", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 18, Format = "h:mm AM/PM" });
            NumberFormats.Add("h:mm:ss AM/PM", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 19, Format = "h:mm:ss AM/PM" });
            NumberFormats.Add("h:mm", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 20, Format = "h:mm" });
            NumberFormats.Add("h:mm:ss", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 21, Format = "h:mm:ss" });
            NumberFormats.Add("m/d/yy h:mm", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 22, Format = "m/d/yy h:mm" });
            NumberFormats.Add("#,##0 ;(#,##0)", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 37, Format = "#,##0 ;(#,##0)" });
            NumberFormats.Add("#,##0 ;[Red](#,##0)", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 38, Format = "#,##0 ;[Red](#,##0)" });
            NumberFormats.Add("#,##0.00;(#,##0.00)", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 39, Format = "#,##0.00;(#,##0.00)" });
            NumberFormats.Add("#,##0.00;[Red](#,##0.00)", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 40, Format = "#,##0.00;[Red](#,#)" });
            NumberFormats.Add("mm:ss", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 45, Format = "mm:ss" });
            NumberFormats.Add("[h]:mm:ss", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 46, Format = "[h]:mm:ss" });
            NumberFormats.Add("mmss.0", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 47, Format = "mmss.0" });
            NumberFormats.Add("##0.0", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 48, Format = "##0.0" });
            NumberFormats.Add("@", new ExcelNumberFormatXml(NameSpaceManager, true) { NumFmtId = 49, Format = "@" });

            NumberFormats.NextId = 164; //Start for custom formats.
        }