getRows static method

MsSsRow getRows(
  1. GetRowsParams rowParams
)

Implementation

static MsSsRow getRows(GetRowsParams rowParams) {
  int rowId = 0;
  String spans = "";
  double height = 0;
  var tempRowId = rowParams.row.getAttribute("r");
  if (tempRowId != null) {
    rowId = int.parse(tempRowId);
  }
  var tempSpans = rowParams.row.getAttribute("spans");
  if (tempSpans != null) {
    spans = tempSpans;
  }
  var tempHeight = rowParams.row.getAttribute("ht");
  if (tempHeight != null) {
    height = double.parse(tempHeight);
  }
  MsSsRow msSsRow = MsSsRow(rowId, spans, height);
  var styleParam = rowParams.row.getAttribute("s");
  if (styleParam != null) {
    msSsRow.style = styleParam;
  }
  var cells = rowParams.row.findAllElements("c");
  if (cells.isNotEmpty) {
    List<MsSsCell> msCells = [];
    for (var cell in cells) {
      int colNo = 0;
      String type = "";
      String value = "";
      int colSpan = 0;
      var tempColNo = cell.getAttribute("r");
      if (tempColNo != null) {
        if (rowParams.mergedCells.contains(tempColNo)) {
          continue;
        }
        colNo = getCellColNo(tempColNo, rowId);
        if (rowParams.mergeCells.isNotEmpty) {
          var mergeCell = rowParams.mergeCells.firstWhereOrNull((mCell) {
            return mCell["from"] == tempColNo;
          });
          if (mergeCell != null) {
            colSpan = getColSpan(mergeCell);
          }
        }
      }
      var tempType = cell.getAttribute("t");
      if (tempType != null) {
        type = tempType;
      }
      var tempValue = cell.findAllElements("v");
      if (tempValue.isNotEmpty) {
        value = tempValue.first.innerText;
      }

      MsSsCell msSsCell = MsSsCell(colNo, type, value, colSpan);
      var tempStyle = cell.getAttribute("s");
      if (tempStyle != null) {
        msSsCell.style = tempStyle;
      }
      msCells.add(msSsCell);
    }
    msSsRow.cells.addAll(msCells);
  }
  return msSsRow;
}