private static void AggregateRows(Interop.Range row2, ref Dictionary <string, object> resultRow, int firstColumnInTableExcelIndex, int lastColumnInTableExcelIndex, int firstRowInTableExcelIndex, int lastRowInTableExcelIndex, Workbook wb, Worksheet activeWS) { try { int tableColumnNum = 1; string columnName; foreach (Interop.Range row2Cell in row2.Columns) { columnName = "Column " + tableColumnNum; if (Transform.usrInputForAggregationProcess.Keys.Contains(columnName)) { // do the operations on the same column for both rows based on the new column type // we know that each cell of the column can be converted to this type because Validator.AllTblColsCanBeParsedToTheNewType() // passed // convert cell from result and cell from row2 to the new column data type switch (Transform.usrInputForAggregationProcess[columnName].ColumnDataType) { case "string": // escape to CSV " to "" StringCellsHandler.AggregateCells(columnName, tableColumnNum, row2Cell, ref resultRow); break; case "double": NumberCellsHandler.AggregateCells(columnName, tableColumnNum, row2Cell, ref resultRow); break; case "boolean": BooleanCellsHandler.AggregateCells(columnName, tableColumnNum, row2Cell, ref resultRow); break; case "datetime": DateTimeCellsHandler.AggregateCells(columnName, tableColumnNum, row2Cell, ref resultRow); break; // 16 March 2018 - cells can't be converted to a "null" column data type //case "null": // EmptyCellsHandler.AggregateCells(columnName, tableColumnNum, row2Cell, ref resultRow); // break; default: throw new Exception($"Can't handle aggregation operation for column data type {Transform.usrInputForAggregationProcess[columnName].ColumnDataType}."); } } tableColumnNum++; } } catch (Exception ex) { throw ex; } }