Esempio n. 1
0
 /// <summary>
 /// 根据IExcelSheet构造一个用于对比的VSheet对象
 /// </summary>
 /// <param name="sheet"></param>
 public VSheet(IExcelSheet sheet, int columnCount)
 {
     _name        = sheet.name;
     _columnCount = columnCount;
     for (int i = 0; i < sheet.rowCount; i++)
     {
         VRow row = new VRow(this, i, sheet.GetRow(i));
         _rows.Add(row);
         if (row.realRowIndex != -1)
         {
             _realRowMap.Add(row.realRowIndex, row);
         }
     }
 }
Esempio n. 2
0
        public void CompareCells(int columnCount, IExcelSheet left, IExcelSheet right)
        {
            _isDifferent = false;
            _cellStatus  = new bool[columnCount];
            IExcelRow leftRow  = left.GetRow(_leftRowIndex);
            IExcelRow rightRow = right.GetRow(_rightRowIndex);

            if (leftRow == null || rightRow == null)
            {
                for (int i = 0; i < columnCount; i++)
                {
                    _cellStatus[i] = true;
                }
            }
            else
            {
                for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
                {
                    IExcelCell selfCell  = leftRow.GetCell(columnIndex);
                    IExcelCell otherCell = rightRow.GetCell(columnIndex);
                    if ((selfCell == null && otherCell != null) || (selfCell != null && otherCell == null))
                    {
                        _cellStatus[columnIndex] = true;
                    }
                    else
                    {
                        if (selfCell == null && otherCell == null)
                        {
                            _cellStatus[columnIndex] = false;
                        }
                        else
                        {
                            _cellStatus[columnIndex] = string.Compare(selfCell.GetContent(), otherCell.GetContent()) != 0;
                        }
                    }
                }
            }

            for (int i = 0; i < _cellStatus.Length; i++)
            {
                if (_cellStatus[i])
                {
                    _isDifferent = true;
                    break;
                }
            }
        }