private void txtNumbers_TextChanged(object sender, EventArgs e) { try { string textBoxValue = txtNumbers.Text; //this will check if textbox is empty if (string.IsNullOrEmpty(txtNumbers.Text)) { txtWord.Clear(); } else { //اذا مو نلل و يحتوي على كسور ف راح يحولة الى كلمة txtWord.Text = InternationalNumericFormatter.FormatWithCulture("L", Convert.ToDouble(txtNumbers.Text), null, new CultureInfo("ar")); } //هنا راح نمسح القديمة ونسوي كلمتين قبل الفاصلة وبعد الفاصلة if (txtNumbers.Text.Contains(".")) { int index = textBoxValue.IndexOf('.'); //قبل الفاصلة int resultBeforePoint = Convert.ToInt32(textBoxValue.Substring(0, index)); //بعد الفاصلة int resultAfterPoint = Convert.ToInt32(textBoxValue.Substring(index + 1)); //الكلمة قبل الفاصلة string wordBeforePoint = InternationalNumericFormatter.FormatWithCulture("L", resultBeforePoint, null, new CultureInfo("ar")); //الكلمة بعد الفاصلة string wordAfterPoint = InternationalNumericFormatter.FormatWithCulture("L", resultAfterPoint, null, new CultureInfo("ar")); //طول الرقم بعد الفاصلة لأحتساب الاعداد العشرية int lengthAfterPoint = Convert.ToString(resultAfterPoint).Length; switch (lengthAfterPoint) { case 3: //بالمئة txtWord.Text = wordBeforePoint + " و " + wordAfterPoint + " بالألف "; break; case 4: txtWord.Text = wordBeforePoint + " و " + wordAfterPoint + " بالعشرة ألاف "; break; case 5: txtWord.Text = wordBeforePoint + " و " + wordAfterPoint + " بالمئة ألف "; break; case 6: case 7: //بالمليون case 8: case 9: txtWord.Text = wordBeforePoint + " و " + wordAfterPoint + " بالمليون "; break; } } } catch { } }
private void ExcelDataToDic(Dictionary <string, string> dicExcel, Dictionary <string, string> result, Range range, bool isNewDictionary) { string name; Cell cell = range[0, 0]; Style style = cell.GetStyle(); string custom = style.CultureCustom != null?style.CultureCustom.ToLower() : ""; string r1C1Formula = cell.R1C1Formula != null?cell.R1C1Formula.ToLower() : ""; #region 判断该名称管理器是否是全局的 不是则进行分隔取出正确的名字 if (range.Name.Contains("!")) { name = range.Name.Split('!')[1] ?? range.Name; } else { name = range.Name; } #endregion decimal d; if (custom.IndexOf("年", StringComparison.Ordinal) >= 0 && cell.StringValue != "") { AsposeHelper.AddItem(isNewDictionary ? result : dicExcel, name, custom.IndexOf("dbnum1", StringComparison.Ordinal) >= 0 ? AsposeHelper.ConvertDate(cell.StringValue, "dbnum1") : AsposeHelper.ConvertDate(cell.StringValue)); } else if (custom.IndexOf("dbnum1", StringComparison.Ordinal) >= 0 && decimal.TryParse(cell.StringValue, out d)) { AsposeHelper.AddItem(isNewDictionary ? result : dicExcel, name, InternationalNumericFormatter.FormatWithCulture("Ln", Convert.ToDecimal(cell.StringValue), null, new CultureInfo("zh-CHS"))); } else if (custom.IndexOf("dbnum2", StringComparison.Ordinal) >= 0 || r1C1Formula.IndexOf("dbnum2", StringComparison.Ordinal) >= 0) { AsposeHelper.AddItem(isNewDictionary ? result : dicExcel, name, AsposeHelper.CmycurD(cell.StringValue)); //InternationalNumericFormatter.FormatWithCulture("L", Convert.ToDecimal(cell.StringValue), null, new CultureInfo("zh-CHS"))); } else { AsposeHelper.AddItem(isNewDictionary ? result : dicExcel, name, AsposeHelper.TryGetDecimal(cell.DisplayStringValue) ? cell.DisplayStringValue.Trim() : cell.DisplayStringValue); } }
/// <summary> /// 获取中文年份 /// </summary> /// <param name="year"></param> /// <returns></returns> private static string GetCnDate(string num, bool isSpecial) { string result = string.Empty; if (isSpecial) { char[] yearChar = num.ToCharArray(); result = yearChar.Aggregate(result, (current, item) => current + InternationalNumericFormatter.FormatWithCulture("Ln", Convert.ToInt32(item.ToString()), null, new CultureInfo("zh-CHS"))); } else { result = InternationalNumericFormatter.FormatWithCulture("Ln", Convert.ToInt32(num), null, new CultureInfo("zh-CHS")); } return(result); }
static void Main(string[] args) { Console.WriteLine("简体中文: " + InternationalNumericFormatter.FormatWithCulture("Ln", 456789, null, new CultureInfo("zh-CHS"))); Console.WriteLine("繁体中文: " + InternationalNumericFormatter.FormatWithCulture("Lc", 456789, null, new CultureInfo("zh-CHT"))); Console.WriteLine("日文: " + InternationalNumericFormatter.FormatWithCulture("L", 456789, null, new CultureInfo("ja"))); // Console.WriteLine("韩文: " + InternationalNumericFormatter.FormatWithCulture("L", 12345, null, new CultureInfo("ko"))); // Console.WriteLine("阿拉伯: " + InternationalNumericFormatter.FormatWithCulture("L", 12345, null, new CultureInfo("ar"))); Console.ReadLine(); }
private string CnUpper(object num) { return(InternationalNumericFormatter.FormatWithCulture("L", num, null, new System.Globalization.CultureInfo("zh-CHS"))); }
static void Main(string[] args) { Debug.WriteLine("The number of 12345 with Normal format and Chinese-Simplified is: " + InternationalNumericFormatter.FormatWithCulture("Ln", 12345, null, new CultureInfo("zh-CHS"))); Debug.WriteLine("The number of 12345 with Currency format and Chinese-Traditional is: " + InternationalNumericFormatter.FormatWithCulture("Lc", 12345, null, new CultureInfo("zh-CHT"))); Debug.WriteLine("The number of 12345 with standard format and Japanese is: " + InternationalNumericFormatter.FormatWithCulture("L", 12345, null, new CultureInfo("ja"))); Debug.WriteLine("The number of 12345 with standard format and Korean is: " + InternationalNumericFormatter.FormatWithCulture("L", 12345, null, new CultureInfo("ko"))); Debug.WriteLine("The number of 12345 with standard format and Arabic is: " + InternationalNumericFormatter.FormatWithCulture("L", 12345, null, new CultureInfo("ar"))); }