private static string GetNumberFormat(string format, string language, out bool isHex, TypeCode typeCode, object originalValue, ref bool isGeneral) { isHex = false; if (string.IsNullOrEmpty(format)) { return("General"); } CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(language); cultureInfo = new CultureInfo(cultureInfo.Name, false); NumberFormatInfo numberFormat = cultureInfo.NumberFormat; if (format.Length > 3) { return(FormatHandler.GetExcelPictureNumberFormat(format)); } if (format.Length == 1) { switch (format[0]) { case 'x': switch (typeCode) { case TypeCode.SByte: case TypeCode.Byte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: isHex = true; return("LOWER(DEC2HEX({0}))"); default: return(string.Empty); } case 'X': switch (typeCode) { case TypeCode.SByte: case TypeCode.Byte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: isHex = true; return("DEC2HEX({0})"); default: return(string.Empty); } case 'C': case 'c': return(FormatHandler.GetCurrencyFormat(numberFormat, numberFormat.CurrencyDecimalDigits)); case 'N': case 'n': return(FormatHandler.GetNumberFormat(numberFormat, numberFormat.NumberDecimalDigits)); case 'G': case 'g': return("General"); default: return(FormatHandler.GetShortNumberFormat(format[0])); } } bool flag = false; int num = default(int); if (int.TryParse(format.Substring(1), out num)) { switch (format[0]) { case 'x': switch (typeCode) { case TypeCode.SByte: case TypeCode.Byte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: isHex = true; return("LOWER(DEC2HEX({0}, " + num + "))"); default: return(string.Empty); } case 'X': switch (typeCode) { case TypeCode.SByte: case TypeCode.Byte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: isHex = true; return("DEC2HEX({0}, " + num + ")"); default: return(string.Empty); } case 'C': case 'c': return(FormatHandler.GetCurrencyFormat(numberFormat, num)); case 'N': case 'n': return(FormatHandler.GetNumberFormat(numberFormat, num)); case 'G': case 'g': { if (originalValue == null) { return(string.Empty); } char generalFormat = FormatHandler.GetGeneralFormat(typeCode, originalValue, num, cultureInfo); isGeneral = true; return(FormatHandler.GetLongNumberFormat(generalFormat, num)); } default: return(FormatHandler.GetLongNumberFormat(format[0], num)); } } return(FormatHandler.GetExcelPictureNumberFormat(format)); }