]> source.dussan.org Git - poi.git/commitdiff
Added Siddharths ExcelComparator
authorAndreas Beeker <kiwiwings@apache.org>
Sat, 8 Aug 2015 00:56:44 +0000 (00:56 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sat, 8 Aug 2015 00:56:44 +0000 (00:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1694753 13f79535-47bb-0310-9956-ffa450edef68

.classpath
src/contrib/src/org/apache/poi/ss/ExcelComparator.java [new file with mode: 0644]

index 5efa12f1e2f3805e93e2088443d574eb42b0e2cb..72367da8d9eb6579c5a785e2852a1c60e7a8f41a 100644 (file)
@@ -10,6 +10,7 @@
        <classpathentry kind="src" path="src/scratchpad/testcases"/>
        <classpathentry kind="src" path="src/resources/scratchpad"/>
        <classpathentry kind="src" path="src/contrib/poi-ruby/java"/>
+       <classpathentry kind="src" path="src/contrib/src"/>
        <classpathentry kind="src" path="src/examples/src"/>
        <classpathentry kind="src" path="src/excelant/java"/>
        <classpathentry kind="src" path="src/excelant/testcases"/>
diff --git a/src/contrib/src/org/apache/poi/ss/ExcelComparator.java b/src/contrib/src/org/apache/poi/ss/ExcelComparator.java
new file mode 100644 (file)
index 0000000..f1e6587
--- /dev/null
@@ -0,0 +1,1348 @@
+/* ====================================================================\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to You under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+==================================================================== */\r
+package org.apache.poi.ss;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.apache.poi.ss.usermodel.Cell;\r
+import org.apache.poi.ss.usermodel.DateUtil;\r
+import org.apache.poi.ss.usermodel.Row;\r
+import org.apache.poi.ss.usermodel.Sheet;\r
+import org.apache.poi.ss.usermodel.Workbook;\r
+import org.apache.poi.ss.util.CellReference;\r
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;\r
+import org.apache.poi.xssf.usermodel.XSSFColor;\r
+\r
+/**\r
+ * Utility to compare Excel File Contents cell by cell for all sheets.\r
+ * \r
+ * <p>This utility will be used to compare Excel File Contents cell by cell for all sheets programmatically.</p>\r
+ * \r
+ * <p>Below are the list of Attribute comparison supported in this version.</p>\r
+ * \r
+ * <ul>\r
+ * <li>Cell Alignment</li>\r
+ * <li>Cell Border Attributes</li>\r
+ * <li>Cell Data</li>\r
+ * <li>Cell Data-Type</li>\r
+ * <li>Cell Fill Color</li>\r
+ * <li>Cell Fill pattern</li>\r
+ * <li>Cell Font Attributes</li>\r
+ * <li>Cell Font Family</li>\r
+ * <li>Cell Font Size</li>\r
+ * <li>Cell Protection</li>\r
+ * <li>Name of the sheets</li>\r
+ * <li>Number of Columns</li>\r
+ * <li>Number of Rows</li>\r
+ * <li>Number of Sheet</li>\r
+ * </ul>\r
+ * \r
+ * <p>(Some of the above attribute comparison only work for *.xlsx format currently. In future it can be enhanced.)</p>\r
+ * \r
+ * <p><b>Usage:</b></p>\r
+ * \r
+ * <pre>\r
+ * {@code\r
+ *  Workbook wb1 = WorkbookFactory.create(new File("workBook1.xls"));\r
+ *  Workbook wb2 = WorkbookFactory.create(new File("workBook2.xls"));\r
+ *  ExcelFileDifference excelFileDifference = ExcelComparator.compare(wb1, wb2);\r
+ *  for (String differences : excelFileDifference.listOfDifferences)\r
+ *      System.out.println(differences);\r
+ *  System.out.println("DifferenceFound = "+ excelFileDifference.isDifferenceFound);\r
+ *  }\r
+ * </pre>\r
+ */\r
+public class ExcelComparator {\r
+\r
+    private static final String BOLD = "BOLD";\r
+    private static final String BOTTOM_BORDER = "BOTTOM BORDER";\r
+    private static final String BRACKET_END = "]";\r
+    private static final String BRACKET_START = " [";\r
+    private static final String CELL_ALIGNMENT_DOES_NOT_MATCH = "Cell Alignment does not Match ::";\r
+    private static final String CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH = "Cell Border Attributes does not Match ::";\r
+    private static final String CELL_DATA_DOES_NOT_MATCH = "Cell Data does not Match ::";\r
+    private static final String CELL_DATA_TYPE_DOES_NOT_MATCH = "Cell Data-Type does not Match in :: ";\r
+    private static final String CELL_FILL_COLOR_DOES_NOT_MATCH = "Cell Fill Color does not Match ::";\r
+    private static final String CELL_FILL_PATTERN_DOES_NOT_MATCH = "Cell Fill pattern does not Match ::";\r
+    private static final String CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH = "Cell Font Attributes does not Match ::";\r
+    private static final String CELL_FONT_FAMILY_DOES_NOT_MATCH = "Cell Font Family does not Match ::";\r
+    private static final String CELL_FONT_SIZE_DOES_NOT_MATCH = "Cell Font Size does not Match ::";\r
+    private static final String CELL_PROTECTION_DOES_NOT_MATCH = "Cell Protection does not Match ::";\r
+    private static final String ITALICS = "ITALICS";\r
+    private static final String LEFT_BORDER = "LEFT BORDER";\r
+    private static final String LINE_SEPARATOR = "line.separator";\r
+    private static final String NAME_OF_THE_SHEETS_DO_NOT_MATCH = "Name of the sheets do not match :: ";\r
+    private static final String NEXT_STR = " -> ";\r
+    private static final String NO_BOTTOM_BORDER = "NO BOTTOM BORDER";\r
+    private static final String NO_COLOR = "NO COLOR";\r
+    private static final String NO_LEFT_BORDER = "NO LEFT BORDER";\r
+    private static final String NO_RIGHT_BORDER = "NO RIGHT BORDER";\r
+    private static final String NO_TOP_BORDER = "NO TOP BORDER";\r
+    private static final String NOT_BOLD = "NOT BOLD";\r
+    private static final String NOT_EQUALS = " != ";\r
+    private static final String NOT_ITALICS = "NOT ITALICS";\r
+    private static final String NOT_UNDERLINE = "NOT UNDERLINE";\r
+    private static final String NUMBER_OF_COLUMNS_DOES_NOT_MATCH = "Number Of Columns does not Match :: ";\r
+    private static final String NUMBER_OF_ROWS_DOES_NOT_MATCH = "Number Of Rows does not Match :: ";\r
+    private static final String NUMBER_OF_SHEETS_DO_NOT_MATCH = "Number of Sheets do not match :: ";\r
+    private static final String RIGHT_BORDER = "RIGHT BORDER";\r
+    private static final String TOP_BORDER = "TOP BORDER";\r
+    private static final String UNDERLINE = "UNDERLINE";\r
+    private static final String WORKBOOK1 = "workbook1";\r
+    private static final String WORKBOOK2 = "workbook2";\r
+\r
+    /**\r
+     * Utility to compare Excel File Contents cell by cell for all sheets.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @return the Excel file difference containing a flag and a list of\r
+     *         differences\r
+     * @throws ExcelCompareException\r
+     *             the excel compare exception\r
+     */\r
+    public static ExcelFileDifference compare(Workbook workbook1,\r
+            Workbook workbook2) {\r
+        List<String> listOfDifferences = compareWorkBookContents(workbook1,\r
+                workbook2);\r
+        return populateListOfDifferences(listOfDifferences);\r
+    }\r
+\r
+    /**\r
+     * Compare work book contents.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @return the list\r
+     */\r
+    private static List<String> compareWorkBookContents(Workbook workbook1,\r
+            Workbook workbook2) {\r
+        ExcelComparator excelComparator = new ExcelComparator();\r
+        List<String> listOfDifferences = new ArrayList<String>();\r
+        excelComparator.compareNumberOfSheets(workbook1, workbook2,\r
+                listOfDifferences);\r
+        excelComparator.compareSheetNames(workbook1, workbook2,\r
+                listOfDifferences);\r
+        excelComparator.compareSheetData(workbook1, workbook2,\r
+                listOfDifferences);\r
+        return listOfDifferences;\r
+    }\r
+\r
+    /**\r
+     * Populate list of differences.\r
+     *\r
+     * @param listOfDifferences\r
+     *            the list of differences\r
+     * @return the excel file difference\r
+     */\r
+    private static ExcelFileDifference populateListOfDifferences(\r
+            List<String> listOfDifferences) {\r
+        ExcelFileDifference excelFileDifference = new ExcelFileDifference();\r
+        excelFileDifference.isDifferenceFound = listOfDifferences.size() > 0;\r
+        excelFileDifference.listOfDifferences = listOfDifferences;\r
+        return excelFileDifference;\r
+    }\r
+\r
+    /**\r
+     * Compare data in all sheets.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @param listOfDifferences\r
+     *            the list of differences\r
+     * @throws ExcelCompareException\r
+     *             the excel compare exception\r
+     */\r
+    private void compareDataInAllSheets(Workbook workbook1, Workbook workbook2,\r
+            List<String> listOfDifferences) {\r
+        for (int i = 0; i < workbook1.getNumberOfSheets(); i++) {\r
+            Sheet sheetWorkBook1 = workbook1.getSheetAt(i);\r
+            Sheet sheetWorkBook2;\r
+            if (workbook2.getNumberOfSheets() > i) {\r
+                sheetWorkBook2 = workbook2.getSheetAt(i);\r
+            } else {\r
+                sheetWorkBook2 = null;\r
+            }\r
+\r
+            for (int j = 0; j < sheetWorkBook1.getPhysicalNumberOfRows(); j++) {\r
+                Row rowWorkBook1 = sheetWorkBook1.getRow(j);\r
+                Row rowWorkBook2;\r
+                if (sheetWorkBook2 != null) {\r
+                    rowWorkBook2 = sheetWorkBook2.getRow(j);\r
+                } else {\r
+                    rowWorkBook2 = null;\r
+                }\r
+\r
+                if ((rowWorkBook1 == null) || (rowWorkBook2 == null)) {\r
+                    continue;\r
+                }\r
+                for (int k = 0; k < rowWorkBook1.getLastCellNum(); k++) {\r
+                    Cell cellWorkBook1 = rowWorkBook1.getCell(k);\r
+                    Cell cellWorkBook2 = rowWorkBook2.getCell(k);\r
+\r
+                    if (!((null == cellWorkBook1) || (null == cellWorkBook2))) {\r
+                        if (isCellTypeMatches(cellWorkBook1, cellWorkBook2)) {\r
+\r
+                            listOfDifferences.add(getMessage(workbook1,\r
+                                    workbook2, i, cellWorkBook1, cellWorkBook2,\r
+                                    CELL_DATA_TYPE_DOES_NOT_MATCH,\r
+                                    cellWorkBook1.getCellType() + "",\r
+                                    cellWorkBook2.getCellType() + ""));\r
+                        }\r
+\r
+                        if (isCellContentTypeBlank(cellWorkBook1)) {\r
+                            if (isCellContentMatches(cellWorkBook1,\r
+                                    cellWorkBook2)) {\r
+\r
+                                listOfDifferences.add(getMessage(workbook1,\r
+                                        workbook2, i, cellWorkBook1,\r
+                                        cellWorkBook2,\r
+                                        CELL_DATA_DOES_NOT_MATCH,\r
+                                        cellWorkBook1.getRichStringCellValue()\r
+                                                + "",\r
+                                        cellWorkBook2.getRichStringCellValue()\r
+                                                + ""));\r
+\r
+                            }\r
+\r
+                        } else if (isCellContentTypeBoolean(cellWorkBook1)) {\r
+                            if (isCellContentMatchesForBoolean(cellWorkBook1,\r
+                                    cellWorkBook2)) {\r
+                                listOfDifferences.add(getMessage(workbook1,\r
+                                        workbook2, i, cellWorkBook1,\r
+                                        cellWorkBook2,\r
+                                        CELL_DATA_DOES_NOT_MATCH,\r
+                                        cellWorkBook1.getBooleanCellValue()\r
+                                                + "",\r
+                                        cellWorkBook2.getBooleanCellValue()\r
+                                                + ""));\r
+\r
+                            }\r
+\r
+                        } else if (isCellContentInError(cellWorkBook1)) {\r
+                            if (isCellContentMatches(cellWorkBook1,\r
+                                    cellWorkBook2)) {\r
+\r
+                                listOfDifferences.add(getMessage(workbook1,\r
+                                        workbook2, i, cellWorkBook1,\r
+                                        cellWorkBook2,\r
+                                        CELL_DATA_DOES_NOT_MATCH,\r
+                                        cellWorkBook1.getRichStringCellValue()\r
+                                                + "",\r
+                                        cellWorkBook2.getRichStringCellValue()\r
+                                                + ""));\r
+\r
+                            }\r
+                        } else if (isCellContentFormula(cellWorkBook1)) {\r
+                            if (isCellContentMatchesForFormula(cellWorkBook1,\r
+                                    cellWorkBook2)) {\r
+\r
+                                listOfDifferences.add(getMessage(workbook1,\r
+                                        workbook2, i, cellWorkBook1,\r
+                                        cellWorkBook2,\r
+                                        CELL_DATA_DOES_NOT_MATCH,\r
+                                        cellWorkBook1.getCellFormula() + "",\r
+                                        cellWorkBook2.getCellFormula() + ""));\r
+\r
+                            }\r
+\r
+                        } else if (isCellContentTypeNumeric(cellWorkBook1)) {\r
+                            if (DateUtil.isCellDateFormatted(cellWorkBook1)) {\r
+                                if (isCellContentMatchesForDate(cellWorkBook1,\r
+                                        cellWorkBook2)) {\r
+                                    listOfDifferences.add(getMessage(workbook1,\r
+                                            workbook2, i, cellWorkBook1,\r
+                                            cellWorkBook2,\r
+                                            CELL_DATA_DOES_NOT_MATCH,\r
+                                            cellWorkBook1.getDateCellValue()\r
+                                                    + "",\r
+                                            cellWorkBook2.getDateCellValue()\r
+                                                    + ""));\r
+\r
+                                }\r
+                            } else {\r
+                                if (isCellContentMatchesForNumeric(\r
+                                        cellWorkBook1, cellWorkBook2)) {\r
+                                    listOfDifferences.add(getMessage(workbook1,\r
+                                            workbook2, i, cellWorkBook1,\r
+                                            cellWorkBook2,\r
+                                            CELL_DATA_DOES_NOT_MATCH,\r
+                                            cellWorkBook1.getNumericCellValue()\r
+                                                    + "",\r
+                                            cellWorkBook2.getNumericCellValue()\r
+                                                    + ""));\r
+\r
+                                }\r
+                            }\r
+\r
+                        } else if (isCellContentTypeString(cellWorkBook1)) {\r
+                            if (isCellContentMatches(cellWorkBook1,\r
+                                    cellWorkBook2)) {\r
+                                listOfDifferences.add(getMessage(workbook1,\r
+                                        workbook2, i, cellWorkBook1,\r
+                                        cellWorkBook2,\r
+                                        CELL_DATA_DOES_NOT_MATCH, cellWorkBook1\r
+                                                .getRichStringCellValue()\r
+                                                .getString(), cellWorkBook2\r
+                                                .getRichStringCellValue()\r
+                                                .getString()));\r
+                            }\r
+                        }\r
+\r
+                        if (isCellFillPatternMatches(cellWorkBook1,\r
+                                cellWorkBook2)) {\r
+                            listOfDifferences.add(getMessage(workbook1,\r
+                                    workbook2, i, cellWorkBook1, cellWorkBook2,\r
+                                    CELL_FILL_PATTERN_DOES_NOT_MATCH,\r
+                                    cellWorkBook1.getCellStyle()\r
+                                            .getFillPattern() + "",\r
+                                    cellWorkBook2.getCellStyle()\r
+                                            .getFillPattern() + ""));\r
+\r
+                        }\r
+\r
+                        if (isCellAlignmentMatches(cellWorkBook1, cellWorkBook2)) {\r
+                            listOfDifferences.add(getMessage(workbook1,\r
+                                    workbook2, i, cellWorkBook1, cellWorkBook2,\r
+                                    CELL_ALIGNMENT_DOES_NOT_MATCH,\r
+                                    cellWorkBook1.getRichStringCellValue()\r
+                                            .getString(), cellWorkBook2\r
+                                            .getRichStringCellValue()\r
+                                            .getString()));\r
+\r
+                        }\r
+\r
+                        if (isCellHiddenMatches(cellWorkBook1, cellWorkBook2)) {\r
+                            listOfDifferences\r
+                                    .add(getMessage(workbook1, workbook2, i,\r
+                                            cellWorkBook1, cellWorkBook2,\r
+                                            CELL_PROTECTION_DOES_NOT_MATCH,\r
+                                            cellWorkBook1.getCellStyle()\r
+                                                    .getHidden() ? "HIDDEN"\r
+                                                    : "NOT HIDDEN",\r
+                                            cellWorkBook2.getCellStyle()\r
+                                                    .getHidden() ? "HIDDEN"\r
+                                                    : "NOT HIDDEN"));\r
+\r
+                        }\r
+\r
+                        if (isCellLockedMatches(cellWorkBook1, cellWorkBook2)) {\r
+                            listOfDifferences\r
+                                    .add(getMessage(workbook1, workbook2, i,\r
+                                            cellWorkBook1, cellWorkBook2,\r
+                                            CELL_PROTECTION_DOES_NOT_MATCH,\r
+                                            cellWorkBook1.getCellStyle()\r
+                                                    .getLocked() ? "LOCKED"\r
+                                                    : "NOT LOCKED",\r
+                                            cellWorkBook2.getCellStyle()\r
+                                                    .getLocked() ? "LOCKED"\r
+                                                    : "NOT LOCKED"));\r
+\r
+                        }\r
+\r
+                        if (isCellFontFamilyMatches(cellWorkBook1,\r
+                                cellWorkBook2)) {\r
+                            listOfDifferences.add(getMessage(workbook1,\r
+                                    workbook2, i, cellWorkBook1, cellWorkBook2,\r
+                                    CELL_FONT_FAMILY_DOES_NOT_MATCH,\r
+                                    ((XSSFCellStyle) cellWorkBook1\r
+                                            .getCellStyle()).getFont()\r
+                                            .getFontName(),\r
+                                    ((XSSFCellStyle) cellWorkBook2\r
+                                            .getCellStyle()).getFont()\r
+                                            .getFontName()));\r
+\r
+                        }\r
+\r
+                        if (isCellFontSizeMatches(cellWorkBook1, cellWorkBook2)) {\r
+                            listOfDifferences.add(getMessage(\r
+                                    workbook1,\r
+                                    workbook2,\r
+                                    i,\r
+                                    cellWorkBook1,\r
+                                    cellWorkBook2,\r
+                                    CELL_FONT_SIZE_DOES_NOT_MATCH,\r
+                                    ((XSSFCellStyle) cellWorkBook1\r
+                                            .getCellStyle()).getFont()\r
+                                            .getFontHeightInPoints()\r
+                                            + "",\r
+                                    ((XSSFCellStyle) cellWorkBook2\r
+                                            .getCellStyle()).getFont()\r
+                                            .getFontHeightInPoints()\r
+                                            + ""));\r
+\r
+                        }\r
+\r
+                        if (isCellFontBoldMatches(cellWorkBook1, cellWorkBook2)) {\r
+                            listOfDifferences.add(getMessage(workbook1,\r
+                                    workbook2, i, cellWorkBook1, cellWorkBook2,\r
+                                    CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH,\r
+                                    ((XSSFCellStyle) cellWorkBook1\r
+                                            .getCellStyle()).getFont()\r
+                                            .getBold() ? BOLD : NOT_BOLD,\r
+                                    ((XSSFCellStyle) cellWorkBook2\r
+                                            .getCellStyle()).getFont()\r
+                                            .getBold() ? BOLD : NOT_BOLD));\r
+\r
+                        }\r
+\r
+                        if (isCellUnderLineMatches(cellWorkBook1, cellWorkBook2)) {\r
+                            listOfDifferences.add(getMessage(workbook1,\r
+                                    workbook2, i, cellWorkBook1, cellWorkBook2,\r
+                                    CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH,\r
+                                    ((XSSFCellStyle) cellWorkBook1\r
+                                            .getCellStyle()).getFont()\r
+                                            .getUnderline() == 1 ? UNDERLINE\r
+                                            : NOT_UNDERLINE,\r
+                                    ((XSSFCellStyle) cellWorkBook2\r
+                                            .getCellStyle()).getFont()\r
+                                            .getUnderline() == 1 ? UNDERLINE\r
+                                            : NOT_UNDERLINE));\r
+\r
+                        }\r
+\r
+                        if (isCellFontItalicsMatches(cellWorkBook1,\r
+                                cellWorkBook2)) {\r
+                            listOfDifferences.add(getMessage(workbook1,\r
+                                    workbook2, i, cellWorkBook1, cellWorkBook2,\r
+                                    CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH,\r
+                                    ((XSSFCellStyle) cellWorkBook1\r
+                                            .getCellStyle()).getFont()\r
+                                            .getItalic() ? ITALICS\r
+                                            : NOT_ITALICS,\r
+                                    ((XSSFCellStyle) cellWorkBook2\r
+                                            .getCellStyle()).getFont()\r
+                                            .getItalic() ? ITALICS\r
+                                            : NOT_ITALICS));\r
+\r
+                        }\r
+\r
+                        if (isCellBorderBottomMatches(cellWorkBook1,\r
+                                cellWorkBook2)) {\r
+                            listOfDifferences\r
+                                    .add(getMessage(\r
+                                            workbook1,\r
+                                            workbook2,\r
+                                            i,\r
+                                            cellWorkBook1,\r
+                                            cellWorkBook2,\r
+                                            CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH,\r
+                                            ((XSSFCellStyle) cellWorkBook1\r
+                                                    .getCellStyle())\r
+                                                    .getBorderBottom() == 1 ? BOTTOM_BORDER\r
+                                                    : NO_BOTTOM_BORDER,\r
+                                            ((XSSFCellStyle) cellWorkBook2\r
+                                                    .getCellStyle())\r
+                                                    .getBorderBottom() == 1 ? BOTTOM_BORDER\r
+                                                    : NO_BOTTOM_BORDER));\r
+\r
+                        }\r
+\r
+                        if (isCellBorderLeftMatches(cellWorkBook1,\r
+                                cellWorkBook2)) {\r
+                            listOfDifferences\r
+                                    .add(getMessage(\r
+                                            workbook1,\r
+                                            workbook2,\r
+                                            i,\r
+                                            cellWorkBook1,\r
+                                            cellWorkBook2,\r
+                                            CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH,\r
+                                            ((XSSFCellStyle) cellWorkBook1\r
+                                                    .getCellStyle())\r
+                                                    .getBorderLeft() == 1 ? LEFT_BORDER\r
+                                                    : NO_LEFT_BORDER,\r
+                                            ((XSSFCellStyle) cellWorkBook2\r
+                                                    .getCellStyle())\r
+                                                    .getBorderLeft() == 1 ? LEFT_BORDER\r
+                                                    : NO_LEFT_BORDER));\r
+\r
+                        }\r
+\r
+                        if (isCellBorderRightMatches(cellWorkBook1,\r
+                                cellWorkBook2)) {\r
+                            listOfDifferences\r
+                                    .add(getMessage(\r
+                                            workbook1,\r
+                                            workbook2,\r
+                                            i,\r
+                                            cellWorkBook1,\r
+                                            cellWorkBook2,\r
+                                            CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH,\r
+                                            ((XSSFCellStyle) cellWorkBook1\r
+                                                    .getCellStyle())\r
+                                                    .getBorderRight() == 1 ? RIGHT_BORDER\r
+                                                    : NO_RIGHT_BORDER,\r
+                                            ((XSSFCellStyle) cellWorkBook2\r
+                                                    .getCellStyle())\r
+                                                    .getBorderRight() == 1 ? RIGHT_BORDER\r
+                                                    : NO_RIGHT_BORDER));\r
+\r
+                        }\r
+\r
+                        if (isCellBorderTopMatches(cellWorkBook1, cellWorkBook2)) {\r
+                            listOfDifferences\r
+                                    .add(getMessage(\r
+                                            workbook1,\r
+                                            workbook2,\r
+                                            i,\r
+                                            cellWorkBook1,\r
+                                            cellWorkBook2,\r
+                                            CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH,\r
+                                            ((XSSFCellStyle) cellWorkBook1\r
+                                                    .getCellStyle())\r
+                                                    .getBorderTop() == 1 ? TOP_BORDER\r
+                                                    : NO_TOP_BORDER,\r
+                                            ((XSSFCellStyle) cellWorkBook2\r
+                                                    .getCellStyle())\r
+                                                    .getBorderTop() == 1 ? TOP_BORDER\r
+                                                    : NO_TOP_BORDER));\r
+\r
+                        }\r
+\r
+                        if (isCellBackGroundFillMatchesAndEmpty(cellWorkBook1,\r
+                                cellWorkBook2)) {\r
+                            continue;\r
+                        } else if (isCellFillBackGroundMatchesAndEitherEmpty(\r
+                                cellWorkBook1, cellWorkBook2)) {\r
+                            listOfDifferences.add(getMessage(\r
+                                    workbook1,\r
+                                    workbook2,\r
+                                    i,\r
+                                    cellWorkBook1,\r
+                                    cellWorkBook2,\r
+                                    CELL_FILL_COLOR_DOES_NOT_MATCH,\r
+                                    NO_COLOR,\r
+                                    ((XSSFColor) cellWorkBook2.getCellStyle()\r
+                                            .getFillForegroundColorColor())\r
+                                            .getARGBHex()\r
+                                            + ""));\r
+\r
+                        } else if (isCellFillBackGroundMatchesAndSecondEmpty(\r
+                                cellWorkBook1, cellWorkBook2)) {\r
+                            listOfDifferences.add(getMessage(\r
+                                    workbook1,\r
+                                    workbook2,\r
+                                    i,\r
+                                    cellWorkBook1,\r
+                                    cellWorkBook2,\r
+                                    CELL_FILL_COLOR_DOES_NOT_MATCH,\r
+                                    ((XSSFColor) cellWorkBook1.getCellStyle()\r
+                                            .getFillForegroundColorColor())\r
+                                            .getARGBHex()\r
+                                            + "", NO_COLOR));\r
+\r
+                        } else {\r
+                            if (isCellFileBackGroundMatches(cellWorkBook1,\r
+                                    cellWorkBook2)) {\r
+                                listOfDifferences.add(getMessage(\r
+                                        workbook1,\r
+                                        workbook2,\r
+                                        i,\r
+                                        cellWorkBook1,\r
+                                        cellWorkBook2,\r
+                                        CELL_FILL_COLOR_DOES_NOT_MATCH,\r
+                                        ((XSSFColor) cellWorkBook1\r
+                                                .getCellStyle()\r
+                                                .getFillForegroundColorColor())\r
+                                                .getARGBHex()\r
+                                                + "",\r
+                                        ((XSSFColor) cellWorkBook2\r
+                                                .getCellStyle()\r
+                                                .getFillForegroundColorColor())\r
+                                                .getARGBHex()\r
+                                                + ""));\r
+\r
+                            }\r
+                        }\r
+\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Compare number of columns in sheets.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @param listOfDifferences\r
+     *            the list of differences\r
+     * @throws ExcelCompareException\r
+     *             the excel compare exception\r
+     */\r
+    private void compareNumberOfColumnsInSheets(Workbook workbook1,\r
+            Workbook workbook2, List<String> listOfDifferences) {\r
+        for (int i = 0; i < workbook1.getNumberOfSheets(); i++) {\r
+            Sheet sheetWorkBook1 = workbook1.getSheetAt(i);\r
+            Sheet sheetWorkBook2;\r
+            if (workbook2.getNumberOfSheets() > i) {\r
+                sheetWorkBook2 = workbook2.getSheetAt(i);\r
+            } else {\r
+                sheetWorkBook2 = null;\r
+            }\r
+            if (isWorkBookEmpty(sheetWorkBook1, sheetWorkBook2)) {\r
+                if (isNumberOfColumnsMatches(sheetWorkBook1, sheetWorkBook2)) {\r
+                    String noOfCols;\r
+                    String sheetName;\r
+                    if (sheetWorkBook2 != null) {\r
+                        noOfCols = sheetWorkBook2.getRow(0).getLastCellNum()\r
+                                + "";\r
+                        sheetName = workbook2.getSheetName(i);\r
+                    } else {\r
+                        noOfCols = "";\r
+                        sheetName = "";\r
+                    }\r
+                    short lastCellNumForWbk1 = sheetWorkBook1.getRow(0) != null ? sheetWorkBook1\r
+                            .getRow(0).getLastCellNum() : 0;\r
+                    listOfDifferences.add(NUMBER_OF_COLUMNS_DOES_NOT_MATCH\r
+                            + System.getProperty(LINE_SEPARATOR) + WORKBOOK1\r
+                            + NEXT_STR + workbook1.getSheetName(i) + NEXT_STR\r
+                            + lastCellNumForWbk1 + NOT_EQUALS + WORKBOOK2\r
+                            + NEXT_STR + sheetName + NEXT_STR + noOfCols);\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Compare number of rows in sheets.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @param listOfDifferences\r
+     *            the list of differences\r
+     * @throws ExcelCompareException\r
+     *             the excel compare exception\r
+     */\r
+    private void compareNumberOfRowsInSheets(Workbook workbook1,\r
+            Workbook workbook2, List<String> listOfDifferences) {\r
+        for (int i = 0; i < workbook1.getNumberOfSheets(); i++) {\r
+            Sheet sheetWorkBook1 = workbook1.getSheetAt(i);\r
+            Sheet sheetWorkBook2;\r
+            if (workbook2.getNumberOfSheets() > i) {\r
+                sheetWorkBook2 = workbook2.getSheetAt(i);\r
+            } else {\r
+                sheetWorkBook2 = null;\r
+            }\r
+            if (isNumberOfRowsMatches(sheetWorkBook1, sheetWorkBook2)) {\r
+                String noOfRows;\r
+                String sheetName;\r
+                if (sheetWorkBook2 != null) {\r
+                    noOfRows = sheetWorkBook2.getPhysicalNumberOfRows() + "";\r
+                    sheetName = workbook2.getSheetName(i);\r
+                } else {\r
+                    noOfRows = "";\r
+                    sheetName = "";\r
+                }\r
+                listOfDifferences.add(NUMBER_OF_ROWS_DOES_NOT_MATCH\r
+                        + System.getProperty(LINE_SEPARATOR) + WORKBOOK1\r
+                        + NEXT_STR + workbook1.getSheetName(i) + NEXT_STR\r
+                        + sheetWorkBook1.getPhysicalNumberOfRows() + NOT_EQUALS\r
+                        + WORKBOOK2 + NEXT_STR + sheetName + NEXT_STR\r
+                        + noOfRows);\r
+            }\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Compare number of sheets.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @param listOfDifferences\r
+     *\r
+     * @throws ExcelCompareException\r
+     *             the excel compare exception\r
+     */\r
+    private void compareNumberOfSheets(Workbook workbook1, Workbook workbook2,\r
+            List<String> listOfDifferences) {\r
+        if (isNumberOfSheetsMatches(workbook1, workbook2)) {\r
+            listOfDifferences.add(NUMBER_OF_SHEETS_DO_NOT_MATCH\r
+                    + System.getProperty(LINE_SEPARATOR) + WORKBOOK1 + NEXT_STR\r
+                    + workbook1.getNumberOfSheets() + NOT_EQUALS + WORKBOOK2\r
+                    + NEXT_STR + workbook2.getNumberOfSheets());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Compare sheet data.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @param listOfDifferences\r
+     *\r
+     * @throws ExcelCompareException\r
+     *             the excel compare exception\r
+     */\r
+    private void compareSheetData(Workbook workbook1, Workbook workbook2,\r
+            List<String> listOfDifferences) {\r
+        compareNumberOfRowsInSheets(workbook1, workbook2, listOfDifferences);\r
+        compareNumberOfColumnsInSheets(workbook1, workbook2, listOfDifferences);\r
+        compareDataInAllSheets(workbook1, workbook2, listOfDifferences);\r
+\r
+    }\r
+\r
+    /**\r
+     * Compare sheet names.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @param listOfDifferences\r
+     *\r
+     * @throws ExcelCompareException\r
+     *             the excel compare exception\r
+     */\r
+    private void compareSheetNames(Workbook workbook1, Workbook workbook2,\r
+            List<String> listOfDifferences) {\r
+        for (int i = 0; i < workbook1.getNumberOfSheets(); i++) {\r
+            if (isNameOfSheetMatches(workbook1, workbook2, i)) {\r
+                String sheetname = workbook2.getNumberOfSheets() > i ? workbook2\r
+                        .getSheetName(i) : "";\r
+                listOfDifferences.add(NAME_OF_THE_SHEETS_DO_NOT_MATCH\r
+                        + System.getProperty(LINE_SEPARATOR) + WORKBOOK1\r
+                        + NEXT_STR + workbook1.getSheetName(i) + BRACKET_START\r
+                        + (i + 1) + BRACKET_END + NOT_EQUALS + WORKBOOK2\r
+                        + NEXT_STR + sheetname + BRACKET_START + (i + 1)\r
+                        + BRACKET_END);\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Gets the message.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @param i\r
+     *            the i\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @param messageStart\r
+     *            the message start\r
+     * @param workBook1Value\r
+     *            the work book1 value\r
+     * @param workBook2Value\r
+     *            the work book2 value\r
+     * @return the message\r
+     */\r
+    private String getMessage(Workbook workbook1, Workbook workbook2, int i,\r
+            Cell cellWorkBook1, Cell cellWorkBook2, String messageStart,\r
+            String workBook1Value, String workBook2Value) {\r
+        StringBuilder sb = new StringBuilder();\r
+        return sb\r
+                .append(messageStart)\r
+                .append(System.getProperty(LINE_SEPARATOR))\r
+                .append(WORKBOOK1)\r
+                .append(NEXT_STR)\r
+                .append(workbook1.getSheetName(i))\r
+                .append(NEXT_STR)\r
+                .append(new CellReference(cellWorkBook1.getRowIndex(),\r
+                        cellWorkBook1.getColumnIndex()).formatAsString())\r
+                .append(BRACKET_START)\r
+                .append(workBook1Value)\r
+                .append(BRACKET_END)\r
+                .append(NOT_EQUALS)\r
+                .append(WORKBOOK2)\r
+                .append(NEXT_STR)\r
+                .append(workbook2.getSheetName(i))\r
+                .append(NEXT_STR)\r
+                .append(new CellReference(cellWorkBook2.getRowIndex(),\r
+                        cellWorkBook2.getColumnIndex()).formatAsString())\r
+                .append(BRACKET_START).append(workBook2Value)\r
+                .append(BRACKET_END).toString();\r
+    }\r
+\r
+    /**\r
+     * Checks if cell alignment matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell alignment matches\r
+     */\r
+    private boolean isCellAlignmentMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        return cellWorkBook1.getCellStyle().getAlignment() != cellWorkBook2\r
+                .getCellStyle().getAlignment();\r
+    }\r
+\r
+    /**\r
+     * Checks if cell back ground fill matches and empty.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell back ground fill matches and empty\r
+     */\r
+    private boolean isCellBackGroundFillMatchesAndEmpty(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        return (cellWorkBook1.getCellStyle().getFillForegroundColorColor() == null)\r
+                && (cellWorkBook2.getCellStyle().getFillForegroundColorColor() == null);\r
+    }\r
+\r
+    /**\r
+     * Checks if cell border bottom matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell border bottom matches\r
+     */\r
+    private boolean isCellBorderBottomMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return ((XSSFCellStyle) cellWorkBook1.getCellStyle())\r
+                    .getBorderBottom() != ((XSSFCellStyle) cellWorkBook2\r
+                    .getCellStyle()).getBorderBottom();\r
+        } else {\r
+            return false;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if cell border left matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell border left matches\r
+     */\r
+    private boolean isCellBorderLeftMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return ((XSSFCellStyle) cellWorkBook1.getCellStyle())\r
+                    .getBorderLeft() != ((XSSFCellStyle) cellWorkBook2\r
+                    .getCellStyle()).getBorderLeft();\r
+        } else {\r
+            return false;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if cell border right matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell border right matches\r
+     */\r
+    private boolean isCellBorderRightMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return ((XSSFCellStyle) cellWorkBook1.getCellStyle())\r
+                    .getBorderRight() != ((XSSFCellStyle) cellWorkBook2\r
+                    .getCellStyle()).getBorderRight();\r
+        } else {\r
+            return false;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if cell border top matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell border top matches\r
+     */\r
+    private boolean isCellBorderTopMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return ((XSSFCellStyle) cellWorkBook1.getCellStyle())\r
+                    .getBorderTop() != ((XSSFCellStyle) cellWorkBook2\r
+                    .getCellStyle()).getBorderTop();\r
+        } else {\r
+            return false;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content formula.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @return true, if cell content formula\r
+     */\r
+    private boolean isCellContentFormula(Cell cellWorkBook1) {\r
+        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_FORMULA;\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content in error.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @return true, if cell content in error\r
+     */\r
+    private boolean isCellContentInError(Cell cellWorkBook1) {\r
+        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_ERROR;\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell content matches\r
+     */\r
+    private boolean isCellContentMatches(Cell cellWorkBook1, Cell cellWorkBook2) {\r
+        return !(cellWorkBook1.getRichStringCellValue().getString()\r
+                .equals(cellWorkBook2.getRichStringCellValue().getString()));\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content matches for boolean.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell content matches for boolean\r
+     */\r
+    private boolean isCellContentMatchesForBoolean(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        return !(cellWorkBook1.getBooleanCellValue() == cellWorkBook2\r
+                .getBooleanCellValue());\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content matches for date.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell content matches for date\r
+     */\r
+    private boolean isCellContentMatchesForDate(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        return !(cellWorkBook1.getDateCellValue().equals(cellWorkBook2\r
+                .getDateCellValue()));\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content matches for formula.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell content matches for formula\r
+     */\r
+    private boolean isCellContentMatchesForFormula(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        return !(cellWorkBook1.getCellFormula().equals(cellWorkBook2\r
+                .getCellFormula()));\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content matches for numeric.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell content matches for numeric\r
+     */\r
+    private boolean isCellContentMatchesForNumeric(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        return !(cellWorkBook1.getNumericCellValue() == cellWorkBook2\r
+                .getNumericCellValue());\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content type blank.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @return true, if cell content type blank\r
+     */\r
+    private boolean isCellContentTypeBlank(Cell cellWorkBook1) {\r
+        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_BLANK;\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content type boolean.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @return true, if cell content type boolean\r
+     */\r
+    private boolean isCellContentTypeBoolean(Cell cellWorkBook1) {\r
+        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_BOOLEAN;\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content type numeric.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @return true, if cell content type numeric\r
+     */\r
+    private boolean isCellContentTypeNumeric(Cell cellWorkBook1) {\r
+        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_NUMERIC;\r
+    }\r
+\r
+    /**\r
+     * Checks if cell content type string.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @return true, if cell content type string\r
+     */\r
+    private boolean isCellContentTypeString(Cell cellWorkBook1) {\r
+        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_STRING;\r
+    }\r
+\r
+    /**\r
+     * Checks if cell file back ground matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell file back ground matches\r
+     */\r
+    private boolean isCellFileBackGroundMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return !((XSSFColor) cellWorkBook1.getCellStyle()\r
+                    .getFillForegroundColorColor()).getARGBHex().equals(\r
+                    ((XSSFColor) cellWorkBook2.getCellStyle()\r
+                            .getFillForegroundColorColor()).getARGBHex());\r
+        } else {\r
+            return false;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if cell fill back ground matches and either empty.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell fill back ground matches and either empty\r
+     */\r
+    private boolean isCellFillBackGroundMatchesAndEitherEmpty(\r
+            Cell cellWorkBook1, Cell cellWorkBook2) {\r
+        return (cellWorkBook1.getCellStyle().getFillForegroundColorColor() == null)\r
+                && (cellWorkBook2.getCellStyle().getFillForegroundColorColor() != null);\r
+    }\r
+\r
+    /**\r
+     * Checks if cell fill back ground matches and second empty.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell fill back ground matches and second empty\r
+     */\r
+    private boolean isCellFillBackGroundMatchesAndSecondEmpty(\r
+            Cell cellWorkBook1, Cell cellWorkBook2) {\r
+        return (cellWorkBook1.getCellStyle().getFillForegroundColorColor() != null)\r
+                && (cellWorkBook2.getCellStyle().getFillForegroundColorColor() == null);\r
+    }\r
+\r
+    /**\r
+     * Checks if cell fill pattern matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell fill pattern matches\r
+     */\r
+    private boolean isCellFillPatternMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        return cellWorkBook1.getCellStyle().getFillPattern() != cellWorkBook2\r
+                .getCellStyle().getFillPattern();\r
+    }\r
+\r
+    /**\r
+     * Checks if cell font bold matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell font bold matches\r
+     */\r
+    private boolean isCellFontBoldMatches(Cell cellWorkBook1, Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return ((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()\r
+                    .getBold() != ((XSSFCellStyle) cellWorkBook2.getCellStyle())\r
+                    .getFont().getBold();\r
+        } else {\r
+            return false;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if cell font family matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell font family matches\r
+     */\r
+    private boolean isCellFontFamilyMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return !(((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()\r
+                    .getFontName().equals(((XSSFCellStyle) cellWorkBook2\r
+                    .getCellStyle()).getFont().getFontName()));\r
+        } else {\r
+            return false;\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Checks if cell font italics matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell font italics matches\r
+     */\r
+    private boolean isCellFontItalicsMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return ((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()\r
+                    .getItalic() != ((XSSFCellStyle) cellWorkBook2\r
+                    .getCellStyle()).getFont().getItalic();\r
+        } else {\r
+            return false;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if cell font size matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell font size matches\r
+     */\r
+    private boolean isCellFontSizeMatches(Cell cellWorkBook1, Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return ((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()\r
+                    .getFontHeightInPoints() != ((XSSFCellStyle) cellWorkBook2\r
+                    .getCellStyle()).getFont().getFontHeightInPoints();\r
+        } else {\r
+            return false;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if cell hidden matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell hidden matches\r
+     */\r
+    private boolean isCellHiddenMatches(Cell cellWorkBook1, Cell cellWorkBook2) {\r
+        return cellWorkBook1.getCellStyle().getHidden() != cellWorkBook2\r
+                .getCellStyle().getHidden();\r
+    }\r
+\r
+    /**\r
+     * Checks if cell locked matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell locked matches\r
+     */\r
+    private boolean isCellLockedMatches(Cell cellWorkBook1, Cell cellWorkBook2) {\r
+        return cellWorkBook1.getCellStyle().getLocked() != cellWorkBook2\r
+                .getCellStyle().getLocked();\r
+    }\r
+\r
+    /**\r
+     * Checks if cell type matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell type matches\r
+     */\r
+    private boolean isCellTypeMatches(Cell cellWorkBook1, Cell cellWorkBook2) {\r
+        return !(cellWorkBook1.getCellType() == cellWorkBook2.getCellType());\r
+    }\r
+\r
+    /**\r
+     * Checks if cell under line matches.\r
+     *\r
+     * @param cellWorkBook1\r
+     *            the cell work book1\r
+     * @param cellWorkBook2\r
+     *            the cell work book2\r
+     * @return true, if cell under line matches\r
+     */\r
+    private boolean isCellUnderLineMatches(Cell cellWorkBook1,\r
+            Cell cellWorkBook2) {\r
+        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {\r
+            return ((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()\r
+                    .getUnderline() != ((XSSFCellStyle) cellWorkBook2\r
+                    .getCellStyle()).getFont().getUnderline();\r
+        } else {\r
+            return false;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if name of sheet matches.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @param i\r
+     *            the i\r
+     * @return true, if name of sheet matches\r
+     */\r
+    private boolean isNameOfSheetMatches(Workbook workbook1,\r
+            Workbook workbook2, int i) {\r
+        if (workbook2.getNumberOfSheets() > i) {\r
+            return !(workbook1.getSheetName(i)\r
+                    .equals(workbook2.getSheetName(i)));\r
+        } else {\r
+            return true;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if number of columns matches.\r
+     *\r
+     * @param sheetWorkBook1\r
+     *            the sheet work book1\r
+     * @param sheetWorkBook2\r
+     *            the sheet work book2\r
+     * @return true, if number of columns matches\r
+     */\r
+    private boolean isNumberOfColumnsMatches(Sheet sheetWorkBook1,\r
+            Sheet sheetWorkBook2) {\r
+        if (sheetWorkBook2 != null) {\r
+            return !(sheetWorkBook1.getRow(0).getLastCellNum() == sheetWorkBook2\r
+                    .getRow(0).getLastCellNum());\r
+        } else {\r
+            return true;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if number of rows matches.\r
+     *\r
+     * @param sheetWorkBook1\r
+     *            the sheet work book1\r
+     * @param sheetWorkBook2\r
+     *            the sheet work book2\r
+     * @return true, if number of rows matches\r
+     */\r
+    private boolean isNumberOfRowsMatches(Sheet sheetWorkBook1,\r
+            Sheet sheetWorkBook2) {\r
+        if (sheetWorkBook2 != null) {\r
+            return !(sheetWorkBook1.getPhysicalNumberOfRows() == sheetWorkBook2\r
+                    .getPhysicalNumberOfRows());\r
+        } else {\r
+            return true;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Checks if number of sheets matches.\r
+     *\r
+     * @param workbook1\r
+     *            the workbook1\r
+     * @param workbook2\r
+     *            the workbook2\r
+     * @return true, if number of sheets matches\r
+     */\r
+    private boolean isNumberOfSheetsMatches(Workbook workbook1,\r
+            Workbook workbook2) {\r
+        return !(workbook1.getNumberOfSheets() == workbook2.getNumberOfSheets());\r
+    }\r
+\r
+    private boolean isWorkBookEmpty(Sheet sheetWorkBook1, Sheet sheetWorkBook2) {\r
+        if (sheetWorkBook2 != null) {\r
+            return !((null == sheetWorkBook1.getRow(0)) || (null == sheetWorkBook2\r
+                    .getRow(0)));\r
+        } else {\r
+            return true;\r
+        }\r
+\r
+    }\r
+\r
+}\r
+\r
+class ExcelFileDifference {\r
+    boolean isDifferenceFound;\r
+    List<String> listOfDifferences;\r
+}\r