What are .NumberFormat Options In Excel VBA?

后端 未结 5 757
小鲜肉
小鲜肉 2020-11-27 12:45

Can you please let me know what are the .NumberFormat format options in Excel VBA? As you are fully aware Excel 2010 supports the following types:

5条回答
  •  一向
    一向 (楼主)
    2020-11-27 13:38

    The .NET Library EPPlus implements a conversation from the string definition to the built in number. See class ExcelNumberFormat:

    internal static int GetFromBuildIdFromFormat(string format)
    {
        switch (format)
        {
            case "General":
                return 0;
            case "0":
                return 1;
            case "0.00":
                return 2;
            case "#,##0":
                return 3;
            case "#,##0.00":
                return 4;
            case "0%":
                return 9;
            case "0.00%":
                return 10;
            case "0.00E+00":
                return 11;
            case "# ?/?":
                return 12;
            case "# ??/??":
                return 13;
            case "mm-dd-yy":
                return 14;
            case "d-mmm-yy":
                return 15;
            case "d-mmm":
                return 16;
            case "mmm-yy":
                return 17;
            case "h:mm AM/PM":
                return 18;
            case "h:mm:ss AM/PM":
                return 19;
            case "h:mm":
                return 20;
            case "h:mm:ss":
                return 21;
            case "m/d/yy h:mm":
                return 22;
            case "#,##0 ;(#,##0)":
                return 37;
            case "#,##0 ;[Red](#,##0)":
                return 38;
            case "#,##0.00;(#,##0.00)":
                return 39;
            case "#,##0.00;[Red](#,#)":
                return 40;
            case "mm:ss":
                return 45;
            case "[h]:mm:ss":
                return 46;
            case "mmss.0":
                return 47;
            case "##0.0":
                return 48;
            case "@":
                return 49;
            default:
                return int.MinValue;
        }
    }
    

    When you use one of these formats, Excel will automatically identify them as a standard format.

提交回复
热议问题