Example #1
0
 public worksheetDifference(
     worksheetInfo UpdatedWorksheet,
     worksheetInfo PreviousWorksheet)
 {
     //if there is no any key column in worksheet
     //comparison cannot be proceed
     //throw exception
     if (UpdatedWorksheet.KeyColumn == 0)
     {
         string msg =
             "Updated workbook " +
             "[" + UpdatedWorksheet.Worksheet.Name + "] " +
             " key column is not available";
         InvalidKeyColumn ex = new InvalidKeyColumn(msg);
         throw ex;
     }
     if (PreviousWorksheet.KeyColumn == 0)
     {
         string msg =
             "Previous workbook " +
             "[" + PreviousWorksheet.Worksheet.Name + "] " +
             " key column is not available";
         InvalidKeyColumn ex = new InvalidKeyColumn(msg);
         throw ex;
     }
     this.UpdatedWorksheet      = UpdatedWorksheet;
     this.PreviousWorksheet     = PreviousWorksheet;
     _resultDataTableCellStatus = new List <CellStatus>();
     initializeResultDataTableColumnAndHeader();
     findAndRenderDeleteRow();
     compareAndRenderRemainingRow();
 }
Example #2
0
        public void LoadWorkbook()
        {
            Console.WriteLine("Start loading filestream: {0}",
                              DateTime.Now.ToString("hh:mm:ss.fff"));
            _updatedFilestream    = new FileStream(this.UpdatedFileFullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            _updatedExcelPackage  = new ExcelPackage(_updatedFilestream);
            _previousFilestream   = new FileStream(this.PreviousFileFullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            _previousExcelPackage = new ExcelPackage(_previousFilestream);
            Console.WriteLine("Start initilize excel package: {0}",
                              DateTime.Now.ToString("hh:mm:ss.fff"));
            _updatedWorkSheets  = new List <worksheetInfo>();
            _previousWorkSheets = new List <worksheetInfo>();

            foreach (ExcelWorksheet wks in _updatedExcelPackage.Workbook.Worksheets)
            {
                Console.WriteLine("Initilize worksheetInfo: {0}",
                                  DateTime.Now.ToString("hh:mm:ss.fff"));
                worksheetInfo wksInfo = new worksheetInfo(wks);
                Console.WriteLine("Copy worksheetInfo to worksheets collection: {0}",
                                  DateTime.Now.ToString("hh:mm:ss.fff"));
                _updatedWorkSheets.Add(wksInfo);
                Console.WriteLine(wks.Name);
                Console.WriteLine("System End Row:" + wksInfo.SystemEndRow);
                Console.WriteLine("System End Column:" + wksInfo.SystemEndColumn);
                Console.WriteLine("True End Row:" + wksInfo.TrueEndRow);
                Console.WriteLine("True End Column:" + wksInfo.TrueEndColumn);
                Console.WriteLine("Date and Time with Milliseconds: {0}",
                                  DateTime.Now.ToString("hh:mm:ss.fff"));
            }
            foreach (ExcelWorksheet wks in _previousExcelPackage.Workbook.Worksheets)
            {
                Console.WriteLine("Initilize worksheetInfo: {0}",
                                  DateTime.Now.ToString("hh:mm:ss.fff"));
                worksheetInfo wksInfo = new worksheetInfo(wks);
                Console.WriteLine("Copy worksheetInfo to worksheets collection: {0}",
                                  DateTime.Now.ToString("hh:mm:ss.fff"));
                _previousWorkSheets.Add(wksInfo);
                Console.WriteLine(wks.Name);
                Console.WriteLine("System End Row:" + wksInfo.SystemEndRow);
                Console.WriteLine("System End Column:" + wksInfo.SystemEndColumn);
                Console.WriteLine("True End Row:" + wksInfo.TrueEndRow);
                Console.WriteLine("True End Column:" + wksInfo.TrueEndColumn);
                Console.WriteLine("Date and Time with Milliseconds: {0}",
                                  DateTime.Now.ToString("hh:mm:ss.fff"));
            }
        }