insertRowIterables method
dynamic
insertRowIterables(})
Adds the row iterables in the given rowIndex = rowIndex in sheet
startingColumn tells from where we should start putting the row iterables
overwriteMergedCells when set to true will over-write mergedCell and does not jumps to next unqiue cell.
overwriteMergedCells when set to false puts the cell value in next unique cell available and putting the value in merged cells only once.
Implementation
insertRowIterables(List<dynamic> row, int rowIndex,
{int startingColumn = 0, bool overwriteMergedCells = true}) {
if (row.length == 0 || rowIndex < 0) {
return;
}
_checkMaxRow(rowIndex);
int columnIndex = 0;
if (startingColumn > 0) {
columnIndex = startingColumn;
}
_checkMaxCol(columnIndex + row.length);
int rowsLength = _maxRows,
maxIterationIndex = row.length - 1,
currentRowPosition = 0; // position in [row] iterables
if (overwriteMergedCells || rowIndex >= rowsLength) {
// Normally iterating and putting the data present in the [row] as we are on the last index.
while (currentRowPosition <= maxIterationIndex) {
_putData(rowIndex, columnIndex, row[currentRowPosition]);
currentRowPosition++;
columnIndex++;
}
} else {
// expensive function as per time complexity
_selfCorrectSpanMap(_excel);
List<_Span> _spanObjectsList = _getSpannedObjects(rowIndex, columnIndex);
if (_spanObjectsList.length <= 0) {
while (currentRowPosition <= maxIterationIndex) {
_putData(rowIndex, columnIndex, row[currentRowPosition]);
currentRowPosition++;
columnIndex++;
}
} else {
while (currentRowPosition <= maxIterationIndex) {
if (_isInsideSpanObject(_spanObjectsList, columnIndex, rowIndex)) {
_putData(rowIndex, columnIndex, row[currentRowPosition]);
currentRowPosition++;
}
columnIndex++;
}
}
}
//int tempo_max_col = columnIndex + row.length - 1;
//if (_maxCols - 1 < tempo_max_col) {
// _maxCols = tempo_max_col + 1;
//}
}