custom static method

CustomNumFormat custom({
  1. required String formatCode,
})

Implementation

static CustomNumFormat custom({
  required String formatCode,
}) {
  if (formatCode == 'General') {
    return CustomNumericNumFormat(formatCode: 'General');
  }

  //const dateParts = ['m', 'mm', 'mmm', 'mmmm', 'mmmmm', 'd', 'dd', 'ddd', 'yy', 'yyyy'];
  //const timeParts = ['h', 'hh', 'm', 'mm', 's', 'ss', 'AM/PM'];

  /// mm appears in dateParts and timeParts, about this from the microsoft website:
  /// > If you use "m" immediately after the "h" or "hh" code or immediately before
  /// > the "ss" code, Excel displays minutes instead of the month.

  /// a very rudamentary check if we're talking date/time/numeric
  /// https://support.microsoft.com/en-us/office/format-numbers-as-dates-or-times-418bd3fe-0577-47c8-8caa-b4d30c528309
  /// or: https://www.ablebits.com/office-addins-blog/custom-excel-number-format/
  /// about dates: https://www.ablebits.com/office-addins-blog/change-date-format-excel/#custom-date-format
  /// about times: https://www.ablebits.com/office-addins-blog/excel-time-format/#custom
  /// [Green]#,##0.00\ \X\X"POSITIV";[Red]\-#\ "Negativ"\.##0.00

  if (_formatCodeLooksLikeDateTime(formatCode)) {
    return CustomDateTimeNumFormat(formatCode: formatCode);
  } else {
    return CustomNumericNumFormat(formatCode: formatCode);
  }
}