private void CompareWorkSheets(string pWbName, PairFiles[] pPairSheets, bool pCompValue, bool pCompStyle, bool pCompShape)
 {
     //copy files to the temp folder
     int nbWorksheets = pPairSheets.Length;
     int wsi = 0;
     foreach (PairFiles pairSheet in pPairSheets)
     {
         this.InfoEvent("Compare workbook " + pWbName + " sheet " + pairSheet.A.Name);
         Worksheet wsA = (Worksheet)pairSheet.A.Object;
         Worksheet wsB = (Worksheet)pairSheet.B.Object;
         Range rgA = wsA.Range[wsA.Cells[1, 1], wsA.UsedRange.SpecialCells(XlCellType.xlCellTypeLastCell)];
         Range rgB = wsB.Range[wsB.Cells[1, 1], wsB.UsedRange.SpecialCells(XlCellType.xlCellTypeLastCell)];
         CompareRanges(pWbName, pairSheet.A.Name, rgA, rgB, pCompValue, pCompStyle, pCompShape);
         if (this.WsProgressEvent != null) this.WsProgressEvent(++wsi, nbWorksheets);
     }
 }
        private void CompareWorkBooks(PairFiles[] pWorkbooksMatch, bool pCompValue, bool pCompStyle, bool pCompShape)
        {
            Application oExcel = CreateExcelApplication();
            if (oExcel != null)
            {
                try
                {
                    int nbWorkbooks = pWorkbooksMatch.Length;
                    int wbi = 0;
                    //int CptWb = 0;
                    foreach (PairFiles wbmatch in pWorkbooksMatch)
                    {
                        //if (CptWb++ == cNbWbRestriction && this.isForeignDomain) {
                        //    System.Windows.Forms.MessageBox.Show("This version is restricted to a maximum of " + cNbWbRestriction + " workbooks.   ", "Info", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                        //    break;
                        //}
                        string pathA = (string)wbmatch.A.Object;
                        string pathB = (string)wbmatch.B.Object;
                        string pathAtmp = CopyFileToTempFolder(pathA, ".a");
                        string pathBtmp = CopyFileToTempFolder(pathB, ".b");
                        if (pathAtmp != null && pathBtmp != null)
                        {
                            Workbook wbA = null;
                            Workbook wbB = null;
                            wbA = OpenWorkbook(oExcel, pathAtmp, wbmatch.A.Name);
                            if (wbA != null)
                            {
                                wbB = OpenWorkbook(oExcel, pathBtmp, wbmatch.B.Name);
                                if (wbB != null)
                                {
                                    ResComp wscomp = Ext.Compare(wbA.Worksheets, wbB.Worksheets);
                                    this.nbSheets += wscomp.lenAandB;
                                    report.add_workbook_top(wbmatch.A.Name, wbA.Name, wbB.Name, wscomp);
                                    CompareWorkSheets(wbmatch.A.Name, wscomp.AandB, pCompValue, pCompStyle, pCompShape);
                                }
                            }
                            if (wbA != null) wbA.Close(false);
                            if (wbB != null) wbB.Close(false);
                            releaseObject((object)wbA);
                            releaseObject((object)wbB);
                        }
                        if (this.WbProgressEvent != null) this.WbProgressEvent(++wbi, nbWorkbooks);
                    }

                }
                catch (Exception)
                {

                }
                finally
                {
                    oExcel.Quit();
                    releaseObject((object)oExcel);
                }
            }
        }