getCellValue static method

String getCellValue(
  1. MsSsCell cell,
  2. List<SharedString> sharedStrings
)

Function for getting cell values

Implementation

static String getCellValue(MsSsCell cell, List<SharedString> sharedStrings) {
  String value = "";
  switch (cell.type) {
    // sharedString
    case 's':
      var sharedString = sharedStrings.firstWhereOrNull((sharedString) {
        return sharedString.index == int.parse(cell.value);
      });
      if (sharedString != null) {
        value = sharedString.text;
      }
      break;
    // boolean
    case 'b':
      value = cell.value == '1' ? "true" : "false";
      break;
    // error
    case 'e':
    // formula
    case 'str':
      value = cell.value;
      break;
    // inline string
    case 'inlineStr':
      value = cell.value;
      break;
    // number
    case 'n':
    default:
      value = cell.value;
  }
  return value;
}