ExcelFormattextHelper.cs 911 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace XYY.Core.Standard.ExcelHelper.MSExcelHelper
  5. {
  6. public static class ExcelFormattextHelper
  7. {
  8. public static string Date => "yyyy-mm-dd";
  9. public static string DateTime => "yyyy-m-d h:mm:ss";
  10. public static string Text => "@";
  11. public static string Percentage => "#0.00%";
  12. public static string Amount => "#,##0.00";
  13. public static string DefaultAmount => "#,##0.000";
  14. public static string GetColumnFormattext(Type pt)
  15. {
  16. if (pt == typeof(string))
  17. return ExcelFormattextHelper.Text;
  18. if (pt == typeof(DateTime))
  19. return ExcelFormattextHelper.DateTime;
  20. if (pt == typeof(decimal))
  21. return ExcelFormattextHelper.Amount;
  22. else
  23. return null;
  24. }
  25. }
  26. }