Beispiel #1
0
 /// <summary>
 /// Make CsvModel rectangle to avoid empty cells.
 /// </summary>
 /// <param name="rowModel"></param>
 private void NormalizeCsvModel(CsvRowModel rowModel)
 {
     if (rowModel.Cells.Count > _prevColumnCount)
     {
         _prevColumnCount = rowModel.Cells.Count;
         foreach (var row in Rows)
         {
             row.NormalizeRow(_prevColumnCount);
         }
     }
     else
     {
         rowModel.NormalizeRow(_prevColumnCount);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Make CsvModel rectangle to avoid empty cells.
 /// </summary>
 /// <param name="rowModel"></param>
 private void NormalizeCsvModel(CsvRowModel rowModel)
 {
     if (rowModel.Cells.Count > _prevColumnCount)
     {
         _prevColumnCount = rowModel.Cells.Count;
         foreach (var row in Rows)
         {
             row.NormalizeRow(_prevColumnCount);
         }
     }
     else
     {
         rowModel.NormalizeRow(_prevColumnCount);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Add new row from excel row (null or empty cell is added as empty cell)
 /// </summary>
 /// <param name="row">excel row</param>
 /// <returns>
 /// true if we add row to model
 /// otherwize false
 /// </returns>
 public bool AddRow(IRow row)
 {
     bool wasNonEmptyCell = false;
     var values = new List<string>();
     for (int i = 0; i < row.LastCellNum; i++) 
     {
         var cellValue = row.CellToStringCsvValue(i);
         if (cellValue != "")
         {
             wasNonEmptyCell = true;
         }
         values.Add(cellValue);
     }
     if (wasNonEmptyCell) // ignore cell with all empty cells.
     {
         var rowModel = new CsvRowModel(values);
         NormalizeCsvModel(rowModel);
         Rows.Add(new CsvRowModel(values));
     }
     return wasNonEmptyCell;
 }
Beispiel #4
0
        /// <summary>
        /// Add new row from excel row (null or empty cell is added as empty cell)
        /// </summary>
        /// <param name="row">excel row</param>
        /// <returns>
        /// true if we add row to model
        /// otherwize false
        /// </returns>
        public bool AddRow(IRow row)
        {
            bool wasNonEmptyCell = false;
            var  values          = new List <string>();

            for (int i = 0; i < row.LastCellNum; i++)
            {
                var cellValue = row.CellToStringCsvValue(i);
                if (cellValue != "")
                {
                    wasNonEmptyCell = true;
                }
                values.Add(cellValue);
            }
            if (wasNonEmptyCell) // ignore cell with all empty cells.
            {
                var rowModel = new CsvRowModel(values);
                NormalizeCsvModel(rowModel);
                Rows.Add(new CsvRowModel(values));
            }
            return(wasNonEmptyCell);
        }