You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/09/13 14:36:58 UTC

svn commit: r1702773 [1/2] - in /poi/trunk/src: contrib/src/ examples/src/org/apache/poi/ss/examples/ examples/src/org/apache/poi/xssf/eventusermodel/ java/org/apache/poi/hssf/record/ ooxml/java/org/apache/poi/xwpf/usermodel/ ooxml/testcases/org/apache...

Author: kiwiwings
Date: Sun Sep 13 12:36:56 2015
New Revision: 1702773

URL: http://svn.apache.org/r1702773
Log:
fix eclipse warning - mostly generics cosmetics
close resources in tests
junit4 conversions
convert spreadsheet based formular test to junit parameterized tests

Added:
    poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java
      - copied, changed from r1701688, poi/trunk/src/contrib/src/org/apache/poi/ss/ExcelComparator.java
Removed:
    poi/trunk/src/contrib/src/
Modified:
    poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java
    poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeInsertion.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestSheet.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java
    poi/trunk/src/testcases/org/apache/poi/ss/formula/function/TestReadMissingBuiltInFuncs.java
    poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java

Copied: poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java (from r1701688, poi/trunk/src/contrib/src/org/apache/poi/ss/ExcelComparator.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java?p2=poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java&p1=poi/trunk/src/contrib/src/org/apache/poi/ss/ExcelComparator.java&r1=1701688&r2=1702773&rev=1702773&view=diff
==============================================================================
--- poi/trunk/src/contrib/src/org/apache/poi/ss/ExcelComparator.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java Sun Sep 13 12:36:56 2015
@@ -14,27 +14,34 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-package org.apache.poi.ss;
+package org.apache.poi.ss.examples;
 
+import java.io.File;
 import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Color;
 import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFColor;
 
 /**
  * Utility to compare Excel File Contents cell by cell for all sheets.
- * 
+ *
  * <p>This utility will be used to compare Excel File Contents cell by cell for all sheets programmatically.</p>
- * 
+ *
  * <p>Below are the list of Attribute comparison supported in this version.</p>
- * 
+ *
  * <ul>
  * <li>Cell Alignment</li>
  * <li>Cell Border Attributes</li>
@@ -51,622 +58,210 @@ import org.apache.poi.xssf.usermodel.XSS
  * <li>Number of Rows</li>
  * <li>Number of Sheet</li>
  * </ul>
- * 
+ *
  * <p>(Some of the above attribute comparison only work for *.xlsx format currently. In future it can be enhanced.)</p>
- * 
+ *
  * <p><b>Usage:</b></p>
- * 
+ *
  * <pre>
  * {@code
  *  Workbook wb1 = WorkbookFactory.create(new File("workBook1.xls"));
  *  Workbook wb2 = WorkbookFactory.create(new File("workBook2.xls"));
- *  ExcelFileDifference excelFileDifference = ExcelComparator.compare(wb1, wb2);
- *  for (String differences : excelFileDifference.listOfDifferences)
+ *  List<String> listOfDifferences = ExcelComparator.compare(wb1, wb2);
+ *  for (String differences : listOfDifferences)
  *      System.out.println(differences);
  *  System.out.println("DifferenceFound = "+ excelFileDifference.isDifferenceFound);
  *  }
  * </pre>
  */
 public class ExcelComparator {
-
-    private static final String BOLD = "BOLD";
-    private static final String BOTTOM_BORDER = "BOTTOM BORDER";
-    private static final String BRACKET_END = "]";
-    private static final String BRACKET_START = " [";
-    private static final String CELL_ALIGNMENT_DOES_NOT_MATCH = "Cell Alignment does not Match ::";
-    private static final String CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH = "Cell Border Attributes does not Match ::";
+    
     private static final String CELL_DATA_DOES_NOT_MATCH = "Cell Data does not Match ::";
-    private static final String CELL_DATA_TYPE_DOES_NOT_MATCH = "Cell Data-Type does not Match in :: ";
-    private static final String CELL_FILL_COLOR_DOES_NOT_MATCH = "Cell Fill Color does not Match ::";
-    private static final String CELL_FILL_PATTERN_DOES_NOT_MATCH = "Cell Fill pattern does not Match ::";
     private static final String CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH = "Cell Font Attributes does not Match ::";
-    private static final String CELL_FONT_FAMILY_DOES_NOT_MATCH = "Cell Font Family does not Match ::";
-    private static final String CELL_FONT_SIZE_DOES_NOT_MATCH = "Cell Font Size does not Match ::";
-    private static final String CELL_PROTECTION_DOES_NOT_MATCH = "Cell Protection does not Match ::";
-    private static final String ITALICS = "ITALICS";
-    private static final String LEFT_BORDER = "LEFT BORDER";
-    private static final String LINE_SEPARATOR = "line.separator";
-    private static final String NAME_OF_THE_SHEETS_DO_NOT_MATCH = "Name of the sheets do not match :: ";
-    private static final String NEXT_STR = " -> ";
-    private static final String NO_BOTTOM_BORDER = "NO BOTTOM BORDER";
-    private static final String NO_COLOR = "NO COLOR";
-    private static final String NO_LEFT_BORDER = "NO LEFT BORDER";
-    private static final String NO_RIGHT_BORDER = "NO RIGHT BORDER";
-    private static final String NO_TOP_BORDER = "NO TOP BORDER";
-    private static final String NOT_BOLD = "NOT BOLD";
-    private static final String NOT_EQUALS = " != ";
-    private static final String NOT_ITALICS = "NOT ITALICS";
-    private static final String NOT_UNDERLINE = "NOT UNDERLINE";
-    private static final String NUMBER_OF_COLUMNS_DOES_NOT_MATCH = "Number Of Columns does not Match :: ";
-    private static final String NUMBER_OF_ROWS_DOES_NOT_MATCH = "Number Of Rows does not Match :: ";
-    private static final String NUMBER_OF_SHEETS_DO_NOT_MATCH = "Number of Sheets do not match :: ";
-    private static final String RIGHT_BORDER = "RIGHT BORDER";
-    private static final String TOP_BORDER = "TOP BORDER";
-    private static final String UNDERLINE = "UNDERLINE";
-    private static final String WORKBOOK1 = "workbook1";
-    private static final String WORKBOOK2 = "workbook2";
 
+    private static class Locator {
+        Workbook workbook;
+        Sheet sheet;
+        Row row;
+        Cell cell;
+    }
+    
+    List<String> listOfDifferences = new ArrayList<String>();
+
+    public static void main(String args[]) throws Exception {
+        if (args.length != 2 || !(new File(args[0]).exists()) || !(new File(args[1]).exists())) {
+            System.err.println("java -cp <classpath> "+ExcelComparator.class.getCanonicalName()+" <workbook1.xls/x> <workbook2.xls/x");
+            System.exit(-1);
+        }
+        Workbook wb1 = WorkbookFactory.create(new File(args[0]));
+        Workbook wb2 = WorkbookFactory.create(new File(args[1]));
+        
+        for (String d : ExcelComparator.compare(wb1, wb2)) {
+            System.out.println(d);
+        }
+        
+        wb2.close();
+        wb1.close();
+    }
+    
     /**
      * Utility to compare Excel File Contents cell by cell for all sheets.
      *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @return the Excel file difference containing a flag and a list of
-     *         differences
-     * @throws ExcelCompareException
-     *             the excel compare exception
-     */
-    public static ExcelFileDifference compare(Workbook workbook1,
-            Workbook workbook2) {
-        List<String> listOfDifferences = compareWorkBookContents(workbook1,
-                workbook2);
-        return populateListOfDifferences(listOfDifferences);
-    }
+     * @param workbook1 the workbook1
+     * @param workbook2 the workbook2
+     * @return the Excel file difference containing a flag and a list of differences
+     * @throws ExcelCompareException the excel compare exception
+     */
+    public static List<String> compare(Workbook wb1, Workbook wb2) {
+        Locator loc1 = new Locator();
+        Locator loc2 = new Locator();
+        loc1.workbook = wb1;
+        loc2.workbook = wb2;
 
-    /**
-     * Compare work book contents.
-     *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @return the list
-     */
-    private static List<String> compareWorkBookContents(Workbook workbook1,
-            Workbook workbook2) {
         ExcelComparator excelComparator = new ExcelComparator();
-        List<String> listOfDifferences = new ArrayList<String>();
-        excelComparator.compareNumberOfSheets(workbook1, workbook2,
-                listOfDifferences);
-        excelComparator.compareSheetNames(workbook1, workbook2,
-                listOfDifferences);
-        excelComparator.compareSheetData(workbook1, workbook2,
-                listOfDifferences);
-        return listOfDifferences;
-    }
+        excelComparator.compareNumberOfSheets(loc1, loc2 );
+        excelComparator.compareSheetNames(loc1, loc2);
+        excelComparator.compareSheetData(loc1, loc2);
 
-    /**
-     * Populate list of differences.
-     *
-     * @param listOfDifferences
-     *            the list of differences
-     * @return the excel file difference
-     */
-    private static ExcelFileDifference populateListOfDifferences(
-            List<String> listOfDifferences) {
-        ExcelFileDifference excelFileDifference = new ExcelFileDifference();
-        excelFileDifference.isDifferenceFound = listOfDifferences.size() > 0;
-        excelFileDifference.listOfDifferences = listOfDifferences;
-        return excelFileDifference;
+        return excelComparator.listOfDifferences;
     }
 
     /**
      * Compare data in all sheets.
      *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @param listOfDifferences
-     *            the list of differences
-     * @throws ExcelCompareException
-     *             the excel compare exception
+     * @param workbook1 the workbook1
+     * @param workbook2 the workbook2
+     * @param listOfDifferences the list of differences
+     * @throws ExcelCompareException the excel compare exception
      */
-    private void compareDataInAllSheets(Workbook workbook1, Workbook workbook2,
-            List<String> listOfDifferences) {
-        for (int i = 0; i < workbook1.getNumberOfSheets(); i++) {
-            Sheet sheetWorkBook1 = workbook1.getSheetAt(i);
-            Sheet sheetWorkBook2;
-            if (workbook2.getNumberOfSheets() > i) {
-                sheetWorkBook2 = workbook2.getSheetAt(i);
-            } else {
-                sheetWorkBook2 = null;
+    private void compareDataInAllSheets(Locator loc1, Locator loc2) {
+        for (int i = 0; i < loc1.workbook.getNumberOfSheets(); i++) {
+            if (loc2.workbook.getNumberOfSheets() <= i) return;
+
+            loc1.sheet = loc1.workbook.getSheetAt(i);
+            loc2.sheet = loc2.workbook.getSheetAt(i);
+
+            compareDataInSheet(loc1, loc2);
+        }
+    }
+
+    private void compareDataInSheet(Locator loc1, Locator loc2) {
+        for (int j = 0; j < loc1.sheet.getPhysicalNumberOfRows(); j++) {
+            if (loc2.sheet.getPhysicalNumberOfRows() <= j) return;
+
+            loc1.row = loc1.sheet.getRow(j);
+            loc2.row = loc2.sheet.getRow(j);
+
+            if ((loc1.row == null) || (loc2.row == null)) {
+                continue;
             }
 
-            for (int j = 0; j < sheetWorkBook1.getPhysicalNumberOfRows(); j++) {
-                Row rowWorkBook1 = sheetWorkBook1.getRow(j);
-                Row rowWorkBook2;
-                if (sheetWorkBook2 != null) {
-                    rowWorkBook2 = sheetWorkBook2.getRow(j);
-                } else {
-                    rowWorkBook2 = null;
-                }
+            compareDataInRow(loc1, loc2);
+        }
+    }
 
-                if ((rowWorkBook1 == null) || (rowWorkBook2 == null)) {
-                    continue;
-                }
-                for (int k = 0; k < rowWorkBook1.getLastCellNum(); k++) {
-                    Cell cellWorkBook1 = rowWorkBook1.getCell(k);
-                    Cell cellWorkBook2 = rowWorkBook2.getCell(k);
-
-                    if (!((null == cellWorkBook1) || (null == cellWorkBook2))) {
-                        if (isCellTypeMatches(cellWorkBook1, cellWorkBook2)) {
-
-                            listOfDifferences.add(getMessage(workbook1,
-                                    workbook2, i, cellWorkBook1, cellWorkBook2,
-                                    CELL_DATA_TYPE_DOES_NOT_MATCH,
-                                    cellWorkBook1.getCellType() + "",
-                                    cellWorkBook2.getCellType() + ""));
-                        }
-
-                        if (isCellContentTypeBlank(cellWorkBook1)) {
-                            if (isCellContentMatches(cellWorkBook1,
-                                    cellWorkBook2)) {
-
-                                listOfDifferences.add(getMessage(workbook1,
-                                        workbook2, i, cellWorkBook1,
-                                        cellWorkBook2,
-                                        CELL_DATA_DOES_NOT_MATCH,
-                                        cellWorkBook1.getRichStringCellValue()
-                                                + "",
-                                        cellWorkBook2.getRichStringCellValue()
-                                                + ""));
-
-                            }
-
-                        } else if (isCellContentTypeBoolean(cellWorkBook1)) {
-                            if (isCellContentMatchesForBoolean(cellWorkBook1,
-                                    cellWorkBook2)) {
-                                listOfDifferences.add(getMessage(workbook1,
-                                        workbook2, i, cellWorkBook1,
-                                        cellWorkBook2,
-                                        CELL_DATA_DOES_NOT_MATCH,
-                                        cellWorkBook1.getBooleanCellValue()
-                                                + "",
-                                        cellWorkBook2.getBooleanCellValue()
-                                                + ""));
-
-                            }
-
-                        } else if (isCellContentInError(cellWorkBook1)) {
-                            if (isCellContentMatches(cellWorkBook1,
-                                    cellWorkBook2)) {
-
-                                listOfDifferences.add(getMessage(workbook1,
-                                        workbook2, i, cellWorkBook1,
-                                        cellWorkBook2,
-                                        CELL_DATA_DOES_NOT_MATCH,
-                                        cellWorkBook1.getRichStringCellValue()
-                                                + "",
-                                        cellWorkBook2.getRichStringCellValue()
-                                                + ""));
-
-                            }
-                        } else if (isCellContentFormula(cellWorkBook1)) {
-                            if (isCellContentMatchesForFormula(cellWorkBook1,
-                                    cellWorkBook2)) {
-
-                                listOfDifferences.add(getMessage(workbook1,
-                                        workbook2, i, cellWorkBook1,
-                                        cellWorkBook2,
-                                        CELL_DATA_DOES_NOT_MATCH,
-                                        cellWorkBook1.getCellFormula() + "",
-                                        cellWorkBook2.getCellFormula() + ""));
-
-                            }
-
-                        } else if (isCellContentTypeNumeric(cellWorkBook1)) {
-                            if (DateUtil.isCellDateFormatted(cellWorkBook1)) {
-                                if (isCellContentMatchesForDate(cellWorkBook1,
-                                        cellWorkBook2)) {
-                                    listOfDifferences.add(getMessage(workbook1,
-                                            workbook2, i, cellWorkBook1,
-                                            cellWorkBook2,
-                                            CELL_DATA_DOES_NOT_MATCH,
-                                            cellWorkBook1.getDateCellValue()
-                                                    + "",
-                                            cellWorkBook2.getDateCellValue()
-                                                    + ""));
-
-                                }
-                            } else {
-                                if (isCellContentMatchesForNumeric(
-                                        cellWorkBook1, cellWorkBook2)) {
-                                    listOfDifferences.add(getMessage(workbook1,
-                                            workbook2, i, cellWorkBook1,
-                                            cellWorkBook2,
-                                            CELL_DATA_DOES_NOT_MATCH,
-                                            cellWorkBook1.getNumericCellValue()
-                                                    + "",
-                                            cellWorkBook2.getNumericCellValue()
-                                                    + ""));
-
-                                }
-                            }
-
-                        } else if (isCellContentTypeString(cellWorkBook1)) {
-                            if (isCellContentMatches(cellWorkBook1,
-                                    cellWorkBook2)) {
-                                listOfDifferences.add(getMessage(workbook1,
-                                        workbook2, i, cellWorkBook1,
-                                        cellWorkBook2,
-                                        CELL_DATA_DOES_NOT_MATCH, cellWorkBook1
-                                                .getRichStringCellValue()
-                                                .getString(), cellWorkBook2
-                                                .getRichStringCellValue()
-                                                .getString()));
-                            }
-                        }
-
-                        if (isCellFillPatternMatches(cellWorkBook1,
-                                cellWorkBook2)) {
-                            listOfDifferences.add(getMessage(workbook1,
-                                    workbook2, i, cellWorkBook1, cellWorkBook2,
-                                    CELL_FILL_PATTERN_DOES_NOT_MATCH,
-                                    cellWorkBook1.getCellStyle()
-                                            .getFillPattern() + "",
-                                    cellWorkBook2.getCellStyle()
-                                            .getFillPattern() + ""));
-
-                        }
-
-                        if (isCellAlignmentMatches(cellWorkBook1, cellWorkBook2)) {
-                            listOfDifferences.add(getMessage(workbook1,
-                                    workbook2, i, cellWorkBook1, cellWorkBook2,
-                                    CELL_ALIGNMENT_DOES_NOT_MATCH,
-                                    cellWorkBook1.getRichStringCellValue()
-                                            .getString(), cellWorkBook2
-                                            .getRichStringCellValue()
-                                            .getString()));
-
-                        }
-
-                        if (isCellHiddenMatches(cellWorkBook1, cellWorkBook2)) {
-                            listOfDifferences
-                                    .add(getMessage(workbook1, workbook2, i,
-                                            cellWorkBook1, cellWorkBook2,
-                                            CELL_PROTECTION_DOES_NOT_MATCH,
-                                            cellWorkBook1.getCellStyle()
-                                                    .getHidden() ? "HIDDEN"
-                                                    : "NOT HIDDEN",
-                                            cellWorkBook2.getCellStyle()
-                                                    .getHidden() ? "HIDDEN"
-                                                    : "NOT HIDDEN"));
-
-                        }
-
-                        if (isCellLockedMatches(cellWorkBook1, cellWorkBook2)) {
-                            listOfDifferences
-                                    .add(getMessage(workbook1, workbook2, i,
-                                            cellWorkBook1, cellWorkBook2,
-                                            CELL_PROTECTION_DOES_NOT_MATCH,
-                                            cellWorkBook1.getCellStyle()
-                                                    .getLocked() ? "LOCKED"
-                                                    : "NOT LOCKED",
-                                            cellWorkBook2.getCellStyle()
-                                                    .getLocked() ? "LOCKED"
-                                                    : "NOT LOCKED"));
-
-                        }
-
-                        if (isCellFontFamilyMatches(cellWorkBook1,
-                                cellWorkBook2)) {
-                            listOfDifferences.add(getMessage(workbook1,
-                                    workbook2, i, cellWorkBook1, cellWorkBook2,
-                                    CELL_FONT_FAMILY_DOES_NOT_MATCH,
-                                    ((XSSFCellStyle) cellWorkBook1
-                                            .getCellStyle()).getFont()
-                                            .getFontName(),
-                                    ((XSSFCellStyle) cellWorkBook2
-                                            .getCellStyle()).getFont()
-                                            .getFontName()));
-
-                        }
-
-                        if (isCellFontSizeMatches(cellWorkBook1, cellWorkBook2)) {
-                            listOfDifferences.add(getMessage(
-                                    workbook1,
-                                    workbook2,
-                                    i,
-                                    cellWorkBook1,
-                                    cellWorkBook2,
-                                    CELL_FONT_SIZE_DOES_NOT_MATCH,
-                                    ((XSSFCellStyle) cellWorkBook1
-                                            .getCellStyle()).getFont()
-                                            .getFontHeightInPoints()
-                                            + "",
-                                    ((XSSFCellStyle) cellWorkBook2
-                                            .getCellStyle()).getFont()
-                                            .getFontHeightInPoints()
-                                            + ""));
-
-                        }
-
-                        if (isCellFontBoldMatches(cellWorkBook1, cellWorkBook2)) {
-                            listOfDifferences.add(getMessage(workbook1,
-                                    workbook2, i, cellWorkBook1, cellWorkBook2,
-                                    CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH,
-                                    ((XSSFCellStyle) cellWorkBook1
-                                            .getCellStyle()).getFont()
-                                            .getBold() ? BOLD : NOT_BOLD,
-                                    ((XSSFCellStyle) cellWorkBook2
-                                            .getCellStyle()).getFont()
-                                            .getBold() ? BOLD : NOT_BOLD));
-
-                        }
-
-                        if (isCellUnderLineMatches(cellWorkBook1, cellWorkBook2)) {
-                            listOfDifferences.add(getMessage(workbook1,
-                                    workbook2, i, cellWorkBook1, cellWorkBook2,
-                                    CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH,
-                                    ((XSSFCellStyle) cellWorkBook1
-                                            .getCellStyle()).getFont()
-                                            .getUnderline() == 1 ? UNDERLINE
-                                            : NOT_UNDERLINE,
-                                    ((XSSFCellStyle) cellWorkBook2
-                                            .getCellStyle()).getFont()
-                                            .getUnderline() == 1 ? UNDERLINE
-                                            : NOT_UNDERLINE));
-
-                        }
-
-                        if (isCellFontItalicsMatches(cellWorkBook1,
-                                cellWorkBook2)) {
-                            listOfDifferences.add(getMessage(workbook1,
-                                    workbook2, i, cellWorkBook1, cellWorkBook2,
-                                    CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH,
-                                    ((XSSFCellStyle) cellWorkBook1
-                                            .getCellStyle()).getFont()
-                                            .getItalic() ? ITALICS
-                                            : NOT_ITALICS,
-                                    ((XSSFCellStyle) cellWorkBook2
-                                            .getCellStyle()).getFont()
-                                            .getItalic() ? ITALICS
-                                            : NOT_ITALICS));
-
-                        }
-
-                        if (isCellBorderBottomMatches(cellWorkBook1,
-                                cellWorkBook2)) {
-                            listOfDifferences
-                                    .add(getMessage(
-                                            workbook1,
-                                            workbook2,
-                                            i,
-                                            cellWorkBook1,
-                                            cellWorkBook2,
-                                            CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH,
-                                            ((XSSFCellStyle) cellWorkBook1
-                                                    .getCellStyle())
-                                                    .getBorderBottom() == 1 ? BOTTOM_BORDER
-                                                    : NO_BOTTOM_BORDER,
-                                            ((XSSFCellStyle) cellWorkBook2
-                                                    .getCellStyle())
-                                                    .getBorderBottom() == 1 ? BOTTOM_BORDER
-                                                    : NO_BOTTOM_BORDER));
-
-                        }
-
-                        if (isCellBorderLeftMatches(cellWorkBook1,
-                                cellWorkBook2)) {
-                            listOfDifferences
-                                    .add(getMessage(
-                                            workbook1,
-                                            workbook2,
-                                            i,
-                                            cellWorkBook1,
-                                            cellWorkBook2,
-                                            CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH,
-                                            ((XSSFCellStyle) cellWorkBook1
-                                                    .getCellStyle())
-                                                    .getBorderLeft() == 1 ? LEFT_BORDER
-                                                    : NO_LEFT_BORDER,
-                                            ((XSSFCellStyle) cellWorkBook2
-                                                    .getCellStyle())
-                                                    .getBorderLeft() == 1 ? LEFT_BORDER
-                                                    : NO_LEFT_BORDER));
-
-                        }
-
-                        if (isCellBorderRightMatches(cellWorkBook1,
-                                cellWorkBook2)) {
-                            listOfDifferences
-                                    .add(getMessage(
-                                            workbook1,
-                                            workbook2,
-                                            i,
-                                            cellWorkBook1,
-                                            cellWorkBook2,
-                                            CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH,
-                                            ((XSSFCellStyle) cellWorkBook1
-                                                    .getCellStyle())
-                                                    .getBorderRight() == 1 ? RIGHT_BORDER
-                                                    : NO_RIGHT_BORDER,
-                                            ((XSSFCellStyle) cellWorkBook2
-                                                    .getCellStyle())
-                                                    .getBorderRight() == 1 ? RIGHT_BORDER
-                                                    : NO_RIGHT_BORDER));
-
-                        }
-
-                        if (isCellBorderTopMatches(cellWorkBook1, cellWorkBook2)) {
-                            listOfDifferences
-                                    .add(getMessage(
-                                            workbook1,
-                                            workbook2,
-                                            i,
-                                            cellWorkBook1,
-                                            cellWorkBook2,
-                                            CELL_BORDER_ATTRIBUTES_DOES_NOT_MATCH,
-                                            ((XSSFCellStyle) cellWorkBook1
-                                                    .getCellStyle())
-                                                    .getBorderTop() == 1 ? TOP_BORDER
-                                                    : NO_TOP_BORDER,
-                                            ((XSSFCellStyle) cellWorkBook2
-                                                    .getCellStyle())
-                                                    .getBorderTop() == 1 ? TOP_BORDER
-                                                    : NO_TOP_BORDER));
-
-                        }
-
-                        if (isCellBackGroundFillMatchesAndEmpty(cellWorkBook1,
-                                cellWorkBook2)) {
-                            continue;
-                        } else if (isCellFillBackGroundMatchesAndEitherEmpty(
-                                cellWorkBook1, cellWorkBook2)) {
-                            listOfDifferences.add(getMessage(
-                                    workbook1,
-                                    workbook2,
-                                    i,
-                                    cellWorkBook1,
-                                    cellWorkBook2,
-                                    CELL_FILL_COLOR_DOES_NOT_MATCH,
-                                    NO_COLOR,
-                                    ((XSSFColor) cellWorkBook2.getCellStyle()
-                                            .getFillForegroundColorColor())
-                                            .getARGBHex()
-                                            + ""));
-
-                        } else if (isCellFillBackGroundMatchesAndSecondEmpty(
-                                cellWorkBook1, cellWorkBook2)) {
-                            listOfDifferences.add(getMessage(
-                                    workbook1,
-                                    workbook2,
-                                    i,
-                                    cellWorkBook1,
-                                    cellWorkBook2,
-                                    CELL_FILL_COLOR_DOES_NOT_MATCH,
-                                    ((XSSFColor) cellWorkBook1.getCellStyle()
-                                            .getFillForegroundColorColor())
-                                            .getARGBHex()
-                                            + "", NO_COLOR));
-
-                        } else {
-                            if (isCellFileBackGroundMatches(cellWorkBook1,
-                                    cellWorkBook2)) {
-                                listOfDifferences.add(getMessage(
-                                        workbook1,
-                                        workbook2,
-                                        i,
-                                        cellWorkBook1,
-                                        cellWorkBook2,
-                                        CELL_FILL_COLOR_DOES_NOT_MATCH,
-                                        ((XSSFColor) cellWorkBook1
-                                                .getCellStyle()
-                                                .getFillForegroundColorColor())
-                                                .getARGBHex()
-                                                + "",
-                                        ((XSSFColor) cellWorkBook2
-                                                .getCellStyle()
-                                                .getFillForegroundColorColor())
-                                                .getARGBHex()
-                                                + ""));
+    private void compareDataInRow(Locator loc1, Locator loc2) {
+        for (int k = 0; k < loc1.row.getLastCellNum(); k++) {
+            if (loc2.row.getPhysicalNumberOfCells() <= k) return;
+
+            loc1.cell = loc1.row.getCell(k);
+            loc2.cell = loc2.row.getCell(k);
 
-                            }
-                        }
+            if ((loc1.cell == null) || (loc2.cell == null)) {
+                continue;
+            }
+
+            compareDataInCell(loc1, loc2);
+        }
+    }
 
-                    }
+    private void compareDataInCell(Locator loc1, Locator loc2) {
+        if (isCellTypeMatches(loc1, loc2)) {
+            switch(loc1.cell.getCellType()) {
+            case Cell.CELL_TYPE_BLANK:
+            case Cell.CELL_TYPE_STRING:
+            case Cell.CELL_TYPE_ERROR:
+                isCellContentMatches(loc1,loc2);
+                break;
+            case Cell.CELL_TYPE_BOOLEAN:
+                isCellContentMatchesForBoolean(loc1,loc2);
+                break;
+            case Cell.CELL_TYPE_FORMULA:
+                isCellContentMatchesForFormula(loc1,loc2);
+                break;
+            case Cell.CELL_TYPE_NUMERIC:
+                if (DateUtil.isCellDateFormatted(loc1.cell)) {
+                    isCellContentMatchesForDate(loc1,loc2);
+                } else {
+                    isCellContentMatchesForNumeric(loc1,loc2);
                 }
+                break;
             }
         }
+
+        isCellFillPatternMatches(loc1,loc2);
+        isCellAlignmentMatches(loc1,loc2);
+        isCellHiddenMatches(loc1,loc2);
+        isCellLockedMatches(loc1,loc2);
+        isCellFontFamilyMatches(loc1,loc2);
+        isCellFontSizeMatches(loc1,loc2);
+        isCellFontBoldMatches(loc1,loc2);
+        isCellUnderLineMatches(loc1,loc2);
+        isCellFontItalicsMatches(loc1,loc2);
+        isCellBorderMatches(loc1,loc2,'t');
+        isCellBorderMatches(loc1,loc2,'l');
+        isCellBorderMatches(loc1,loc2,'b');
+        isCellBorderMatches(loc1,loc2,'r');
+        isCellFillBackGroundMatches(loc1,loc2);
     }
 
     /**
      * Compare number of columns in sheets.
-     *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @param listOfDifferences
-     *            the list of differences
-     * @throws ExcelCompareException
-     *             the excel compare exception
      */
-    private void compareNumberOfColumnsInSheets(Workbook workbook1,
-            Workbook workbook2, List<String> listOfDifferences) {
-        for (int i = 0; i < workbook1.getNumberOfSheets(); i++) {
-            Sheet sheetWorkBook1 = workbook1.getSheetAt(i);
-            Sheet sheetWorkBook2;
-            if (workbook2.getNumberOfSheets() > i) {
-                sheetWorkBook2 = workbook2.getSheetAt(i);
-            } else {
-                sheetWorkBook2 = null;
-            }
-            if (isWorkBookEmpty(sheetWorkBook1, sheetWorkBook2)) {
-                if (isNumberOfColumnsMatches(sheetWorkBook1, sheetWorkBook2)) {
-                    String noOfCols;
-                    String sheetName;
-                    if (sheetWorkBook2 != null) {
-                        noOfCols = sheetWorkBook2.getRow(0).getLastCellNum()
-                                + "";
-                        sheetName = workbook2.getSheetName(i);
-                    } else {
-                        noOfCols = "";
-                        sheetName = "";
-                    }
-                    short lastCellNumForWbk1 = sheetWorkBook1.getRow(0) != null ? sheetWorkBook1
-                            .getRow(0).getLastCellNum() : 0;
-                    listOfDifferences.add(NUMBER_OF_COLUMNS_DOES_NOT_MATCH
-                            + System.getProperty(LINE_SEPARATOR) + WORKBOOK1
-                            + NEXT_STR + workbook1.getSheetName(i) + NEXT_STR
-                            + lastCellNumForWbk1 + NOT_EQUALS + WORKBOOK2
-                            + NEXT_STR + sheetName + NEXT_STR + noOfCols);
-                }
+    private void compareNumberOfColumnsInSheets(Locator loc1, Locator loc2) {
+        for (int i = 0; i < loc1.workbook.getNumberOfSheets(); i++) {
+            if (loc2.workbook.getNumberOfSheets() <= i) return;
+            
+            loc1.sheet = loc1.workbook.getSheetAt(i);
+            loc2.sheet = loc2.workbook.getSheetAt(i);
+
+            Iterator<Row> ri1 = loc1.sheet.rowIterator();
+            Iterator<Row> ri2 = loc2.sheet.rowIterator();
+            
+            int num1 = (ri1.hasNext()) ? ri1.next().getPhysicalNumberOfCells() : 0;
+            int num2 = (ri2.hasNext()) ? ri2.next().getPhysicalNumberOfCells() : 0;
+            
+            if (num1 != num2) {
+                String str = String.format(Locale.ROOT, "%s\nworkbook1 -> %s [%d] != workbook2 -> %s [%d]",
+                    "Number Of Columns does not Match ::",
+                    loc1.sheet.getSheetName(), num1,
+                    loc2.sheet.getSheetName(), num2
+                );
+                listOfDifferences.add(str);
             }
         }
     }
 
     /**
      * Compare number of rows in sheets.
-     *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @param listOfDifferences
-     *            the list of differences
-     * @throws ExcelCompareException
-     *             the excel compare exception
      */
-    private void compareNumberOfRowsInSheets(Workbook workbook1,
-            Workbook workbook2, List<String> listOfDifferences) {
-        for (int i = 0; i < workbook1.getNumberOfSheets(); i++) {
-            Sheet sheetWorkBook1 = workbook1.getSheetAt(i);
-            Sheet sheetWorkBook2;
-            if (workbook2.getNumberOfSheets() > i) {
-                sheetWorkBook2 = workbook2.getSheetAt(i);
-            } else {
-                sheetWorkBook2 = null;
-            }
-            if (isNumberOfRowsMatches(sheetWorkBook1, sheetWorkBook2)) {
-                String noOfRows;
-                String sheetName;
-                if (sheetWorkBook2 != null) {
-                    noOfRows = sheetWorkBook2.getPhysicalNumberOfRows() + "";
-                    sheetName = workbook2.getSheetName(i);
-                } else {
-                    noOfRows = "";
-                    sheetName = "";
-                }
-                listOfDifferences.add(NUMBER_OF_ROWS_DOES_NOT_MATCH
-                        + System.getProperty(LINE_SEPARATOR) + WORKBOOK1
-                        + NEXT_STR + workbook1.getSheetName(i) + NEXT_STR
-                        + sheetWorkBook1.getPhysicalNumberOfRows() + NOT_EQUALS
-                        + WORKBOOK2 + NEXT_STR + sheetName + NEXT_STR
-                        + noOfRows);
+    private void compareNumberOfRowsInSheets(Locator loc1, Locator loc2) {
+        for (int i = 0; i < loc1.workbook.getNumberOfSheets(); i++) {
+            if (loc2.workbook.getNumberOfSheets() <= i) return;
+
+            loc1.sheet = loc1.workbook.getSheetAt(i);
+            loc2.sheet = loc2.workbook.getSheetAt(i);
+            
+            int num1 = loc1.sheet.getPhysicalNumberOfRows();
+            int num2 = loc2.sheet.getPhysicalNumberOfRows();
+
+            if (num1 != num2) {
+                String str = String.format(Locale.ROOT, "%s\nworkbook1 -> %s [%d] != workbook2 -> %s [%d]",
+                    "Number Of Rows does not Match ::",
+                    loc1.sheet.getSheetName(), num1,
+                    loc2.sheet.getSheetName(), num2
+                );
+                listOfDifferences.add(str);
             }
         }
 
@@ -674,23 +269,18 @@ public class ExcelComparator {
 
     /**
      * Compare number of sheets.
-     *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @param listOfDifferences
-     *
-     * @throws ExcelCompareException
-     *             the excel compare exception
      */
-    private void compareNumberOfSheets(Workbook workbook1, Workbook workbook2,
-            List<String> listOfDifferences) {
-        if (isNumberOfSheetsMatches(workbook1, workbook2)) {
-            listOfDifferences.add(NUMBER_OF_SHEETS_DO_NOT_MATCH
-                    + System.getProperty(LINE_SEPARATOR) + WORKBOOK1 + NEXT_STR
-                    + workbook1.getNumberOfSheets() + NOT_EQUALS + WORKBOOK2
-                    + NEXT_STR + workbook2.getNumberOfSheets());
+    private void compareNumberOfSheets(Locator loc1, Locator loc2) {
+        int num1 = loc1.workbook.getNumberOfSheets();
+        int num2 = loc2.workbook.getNumberOfSheets();
+        if (num1 != num2) {
+            String str = String.format(Locale.ROOT, "%s\nworkbook1 [%d] != workbook2 [%d]",
+                "Number of Sheets do not match ::",
+                num1, num2
+            );
+
+            listOfDifferences.add(str);
+            
         }
     }
 
@@ -706,531 +296,295 @@ public class ExcelComparator {
      * @throws ExcelCompareException
      *             the excel compare exception
      */
-    private void compareSheetData(Workbook workbook1, Workbook workbook2,
-            List<String> listOfDifferences) {
-        compareNumberOfRowsInSheets(workbook1, workbook2, listOfDifferences);
-        compareNumberOfColumnsInSheets(workbook1, workbook2, listOfDifferences);
-        compareDataInAllSheets(workbook1, workbook2, listOfDifferences);
+    private void compareSheetData(Locator loc1, Locator loc2) {
+        compareNumberOfRowsInSheets(loc1, loc2);
+        compareNumberOfColumnsInSheets(loc1, loc2);
+        compareDataInAllSheets(loc1, loc2);
 
     }
 
     /**
      * Compare sheet names.
-     *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @param listOfDifferences
-     *
-     * @throws ExcelCompareException
-     *             the excel compare exception
      */
-    private void compareSheetNames(Workbook workbook1, Workbook workbook2,
-            List<String> listOfDifferences) {
-        for (int i = 0; i < workbook1.getNumberOfSheets(); i++) {
-            if (isNameOfSheetMatches(workbook1, workbook2, i)) {
-                String sheetname = workbook2.getNumberOfSheets() > i ? workbook2
-                        .getSheetName(i) : "";
-                listOfDifferences.add(NAME_OF_THE_SHEETS_DO_NOT_MATCH
-                        + System.getProperty(LINE_SEPARATOR) + WORKBOOK1
-                        + NEXT_STR + workbook1.getSheetName(i) + BRACKET_START
-                        + (i + 1) + BRACKET_END + NOT_EQUALS + WORKBOOK2
-                        + NEXT_STR + sheetname + BRACKET_START + (i + 1)
-                        + BRACKET_END);
+    private void compareSheetNames(Locator loc1, Locator loc2) {
+        for (int i = 0; i < loc1.workbook.getNumberOfSheets(); i++) {
+            String name1 = loc1.workbook.getSheetName(i);
+            String name2 = (loc2.workbook.getNumberOfSheets() > i) ? loc2.workbook.getSheetName(i) : "";
+            
+            if (!name1.equals(name2)) {
+                String str = String.format(Locale.ROOT, "%s\nworkbook1 -> %s [%d] != workbook2 -> %s [%d]",
+                    "Name of the sheets do not match ::",
+                    loc1.sheet.getSheetName(), name1, i+1,
+                    loc2.sheet.getSheetName(), name2, i+1
+                );
+                listOfDifferences.add(str);
             }
         }
     }
 
     /**
-     * Gets the message.
-     *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @param i
-     *            the i
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @param messageStart
-     *            the message start
-     * @param workBook1Value
-     *            the work book1 value
-     * @param workBook2Value
-     *            the work book2 value
-     * @return the message
-     */
-    private String getMessage(Workbook workbook1, Workbook workbook2, int i,
-            Cell cellWorkBook1, Cell cellWorkBook2, String messageStart,
-            String workBook1Value, String workBook2Value) {
-        StringBuilder sb = new StringBuilder();
-        return sb
-                .append(messageStart)
-                .append(System.getProperty(LINE_SEPARATOR))
-                .append(WORKBOOK1)
-                .append(NEXT_STR)
-                .append(workbook1.getSheetName(i))
-                .append(NEXT_STR)
-                .append(new CellReference(cellWorkBook1.getRowIndex(),
-                        cellWorkBook1.getColumnIndex()).formatAsString())
-                .append(BRACKET_START)
-                .append(workBook1Value)
-                .append(BRACKET_END)
-                .append(NOT_EQUALS)
-                .append(WORKBOOK2)
-                .append(NEXT_STR)
-                .append(workbook2.getSheetName(i))
-                .append(NEXT_STR)
-                .append(new CellReference(cellWorkBook2.getRowIndex(),
-                        cellWorkBook2.getColumnIndex()).formatAsString())
-                .append(BRACKET_START).append(workBook2Value)
-                .append(BRACKET_END).toString();
-    }
-
-    /**
-     * Checks if cell alignment matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell alignment matches
+     * Formats the message.
      */
-    private boolean isCellAlignmentMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        return cellWorkBook1.getCellStyle().getAlignment() != cellWorkBook2
-                .getCellStyle().getAlignment();
+    private void addMessage(Locator loc1, Locator loc2, String messageStart, String value1, String value2) {
+        String str =
+            String.format(Locale.ROOT, "%s\nworkbook1 -> %s -> %s [%s] != workbook2 -> %s -> %s [%s]",
+                messageStart,
+                loc1.sheet.getSheetName(), new CellReference(loc1.cell).formatAsString(), value1,
+                loc2.sheet.getSheetName(), new CellReference(loc2.cell).formatAsString(), value2
+            );
+        listOfDifferences.add(str);
     }
 
     /**
-     * Checks if cell back ground fill matches and empty.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell back ground fill matches and empty
+     * Checks if cell alignment matches.
      */
-    private boolean isCellBackGroundFillMatchesAndEmpty(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        return (cellWorkBook1.getCellStyle().getFillForegroundColorColor() == null)
-                && (cellWorkBook2.getCellStyle().getFillForegroundColorColor() == null);
+    private void isCellAlignmentMatches(Locator loc1, Locator loc2) {
+        // TODO: check for NPE
+        short align1 = loc1.cell.getCellStyle().getAlignment();
+        short align2 = loc2.cell.getCellStyle().getAlignment();
+        if (align1 != align2) {
+            addMessage(loc1, loc2,
+                "Cell Alignment does not Match ::",
+                Short.toString(align1),
+                Short.toString(align2)
+            );
+        }
     }
 
     /**
      * Checks if cell border bottom matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell border bottom matches
      */
-    private boolean isCellBorderBottomMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return ((XSSFCellStyle) cellWorkBook1.getCellStyle())
-                    .getBorderBottom() != ((XSSFCellStyle) cellWorkBook2
-                    .getCellStyle()).getBorderBottom();
-        } else {
-            return false;
+    private void isCellBorderMatches(Locator loc1, Locator loc2, char borderSide) {
+        if (!(loc1.cell instanceof XSSFCell)) return;
+        XSSFCellStyle style1 = ((XSSFCell)loc1.cell).getCellStyle();
+        XSSFCellStyle style2 = ((XSSFCell)loc2.cell).getCellStyle();
+        boolean b1, b2;
+        String borderName;
+        switch (borderSide) {
+            case 't': default:
+                b1 = style1.getBorderTop() == 1;
+                b2 = style2.getBorderTop() == 1;
+                borderName = "TOP";
+                break;
+            case 'b':
+                b1 = style1.getBorderBottom() == 1;
+                b2 = style2.getBorderBottom() == 1;
+                borderName = "BOTTOM";
+                break;
+            case 'l':
+                b1 = style1.getBorderLeft() == 1;
+                b2 = style2.getBorderLeft() == 1;
+                borderName = "LEFT";
+                break;
+            case 'r':
+                b1 = style1.getBorderRight() == 1;
+                b2 = style2.getBorderRight() == 1;
+                borderName = "RIGHT";
+                break;
+        }
+        if (b1 != b2) {
+            addMessage(loc1, loc2,
+                "Cell Border Attributes does not Match ::",
+                (b1 ? "" : "NOT ")+borderName+" BORDER",
+                (b2 ? "" : "NOT ")+borderName+" BORDER"
+            );
         }
-
     }
 
     /**
-     * Checks if cell border left matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell border left matches
+     * Checks if cell content matches.
      */
-    private boolean isCellBorderLeftMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return ((XSSFCellStyle) cellWorkBook1.getCellStyle())
-                    .getBorderLeft() != ((XSSFCellStyle) cellWorkBook2
-                    .getCellStyle()).getBorderLeft();
-        } else {
-            return false;
+    private void isCellContentMatches(Locator loc1, Locator loc2) {
+        // TODO: check for null and non-rich-text cells
+        String str1 = loc1.cell.getRichStringCellValue().getString();
+        String str2 = loc2.cell.getRichStringCellValue().getString();
+        if (!str1.equals(str2)) {
+            addMessage(loc1,loc2,CELL_DATA_DOES_NOT_MATCH,str1,str2);
         }
-
     }
 
     /**
-     * Checks if cell border right matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell border right matches
+     * Checks if cell content matches for boolean.
      */
-    private boolean isCellBorderRightMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return ((XSSFCellStyle) cellWorkBook1.getCellStyle())
-                    .getBorderRight() != ((XSSFCellStyle) cellWorkBook2
-                    .getCellStyle()).getBorderRight();
-        } else {
-            return false;
+    private void isCellContentMatchesForBoolean(Locator loc1, Locator loc2) {
+        boolean b1 = loc1.cell.getBooleanCellValue();
+        boolean b2 = loc2.cell.getBooleanCellValue();
+        if (b1 != b2) {
+            addMessage(loc1,loc2,CELL_DATA_DOES_NOT_MATCH,Boolean.toString(b1),Boolean.toString(b2));
         }
-
     }
 
     /**
-     * Checks if cell border top matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell border top matches
+     * Checks if cell content matches for date.
      */
-    private boolean isCellBorderTopMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return ((XSSFCellStyle) cellWorkBook1.getCellStyle())
-                    .getBorderTop() != ((XSSFCellStyle) cellWorkBook2
-                    .getCellStyle()).getBorderTop();
-        } else {
-            return false;
+    private void isCellContentMatchesForDate(Locator loc1, Locator loc2) {
+        Date date1 = loc1.cell.getDateCellValue();
+        Date date2 = loc2.cell.getDateCellValue();
+        if (!date1.equals(date2)) {
+            addMessage(loc1, loc2, CELL_DATA_DOES_NOT_MATCH, date1.toGMTString(), date2.toGMTString());
         }
-
-    }
-
-    /**
-     * Checks if cell content formula.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @return true, if cell content formula
-     */
-    private boolean isCellContentFormula(Cell cellWorkBook1) {
-        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_FORMULA;
-    }
-
-    /**
-     * Checks if cell content in error.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @return true, if cell content in error
-     */
-    private boolean isCellContentInError(Cell cellWorkBook1) {
-        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_ERROR;
-    }
-
-    /**
-     * Checks if cell content matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell content matches
-     */
-    private boolean isCellContentMatches(Cell cellWorkBook1, Cell cellWorkBook2) {
-        return !(cellWorkBook1.getRichStringCellValue().getString()
-                .equals(cellWorkBook2.getRichStringCellValue().getString()));
-    }
-
-    /**
-     * Checks if cell content matches for boolean.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell content matches for boolean
-     */
-    private boolean isCellContentMatchesForBoolean(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        return !(cellWorkBook1.getBooleanCellValue() == cellWorkBook2
-                .getBooleanCellValue());
     }
 
-    /**
-     * Checks if cell content matches for date.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell content matches for date
-     */
-    private boolean isCellContentMatchesForDate(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        return !(cellWorkBook1.getDateCellValue().equals(cellWorkBook2
-                .getDateCellValue()));
-    }
 
     /**
      * Checks if cell content matches for formula.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell content matches for formula
      */
-    private boolean isCellContentMatchesForFormula(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        return !(cellWorkBook1.getCellFormula().equals(cellWorkBook2
-                .getCellFormula()));
+    private void isCellContentMatchesForFormula(Locator loc1, Locator loc2) {
+        // TODO: actually evaluate the formula / NPE checks
+        String form1 = loc1.cell.getCellFormula();
+        String form2 = loc2.cell.getCellFormula();
+        if (!form1.equals(form2)) {
+            addMessage(loc1, loc2, CELL_DATA_DOES_NOT_MATCH, form1, form2);
+        }
     }
 
     /**
      * Checks if cell content matches for numeric.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell content matches for numeric
-     */
-    private boolean isCellContentMatchesForNumeric(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        return !(cellWorkBook1.getNumericCellValue() == cellWorkBook2
-                .getNumericCellValue());
-    }
-
-    /**
-     * Checks if cell content type blank.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @return true, if cell content type blank
-     */
-    private boolean isCellContentTypeBlank(Cell cellWorkBook1) {
-        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_BLANK;
-    }
-
-    /**
-     * Checks if cell content type boolean.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @return true, if cell content type boolean
-     */
-    private boolean isCellContentTypeBoolean(Cell cellWorkBook1) {
-        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_BOOLEAN;
-    }
-
-    /**
-     * Checks if cell content type numeric.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @return true, if cell content type numeric
      */
-    private boolean isCellContentTypeNumeric(Cell cellWorkBook1) {
-        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_NUMERIC;
+    private void isCellContentMatchesForNumeric(Locator loc1, Locator loc2) {
+        // TODO: Check for NaN
+        double num1 = loc1.cell.getNumericCellValue();
+        double num2 = loc2.cell.getNumericCellValue();
+        if (num1 != num2) {
+            addMessage(loc1, loc2, CELL_DATA_DOES_NOT_MATCH, Double.toString(num1), Double.toString(num2));
+        }
     }
 
-    /**
-     * Checks if cell content type string.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @return true, if cell content type string
-     */
-    private boolean isCellContentTypeString(Cell cellWorkBook1) {
-        return cellWorkBook1.getCellType() == Cell.CELL_TYPE_STRING;
+    private String getCellFillBackground(Locator loc) {
+        Color col = loc.cell.getCellStyle().getFillForegroundColorColor();
+        return (col instanceof XSSFColor) ? ((XSSFColor)col).getARGBHex() : "NO COLOR";
     }
-
+    
     /**
      * Checks if cell file back ground matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell file back ground matches
      */
-    private boolean isCellFileBackGroundMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return !((XSSFColor) cellWorkBook1.getCellStyle()
-                    .getFillForegroundColorColor()).getARGBHex().equals(
-                    ((XSSFColor) cellWorkBook2.getCellStyle()
-                            .getFillForegroundColorColor()).getARGBHex());
-        } else {
-            return false;
+    private void isCellFillBackGroundMatches(Locator loc1, Locator loc2) {
+        String col1 = getCellFillBackground(loc1);
+        String col2 = getCellFillBackground(loc2);
+        if (!col1.equals(col2)) {
+            addMessage(loc1, loc2, "Cell Fill Color does not Match ::", col1, col2);
         }
-
-    }
-
-    /**
-     * Checks if cell fill back ground matches and either empty.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell fill back ground matches and either empty
-     */
-    private boolean isCellFillBackGroundMatchesAndEitherEmpty(
-            Cell cellWorkBook1, Cell cellWorkBook2) {
-        return (cellWorkBook1.getCellStyle().getFillForegroundColorColor() == null)
-                && (cellWorkBook2.getCellStyle().getFillForegroundColorColor() != null);
     }
-
-    /**
-     * Checks if cell fill back ground matches and second empty.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell fill back ground matches and second empty
-     */
-    private boolean isCellFillBackGroundMatchesAndSecondEmpty(
-            Cell cellWorkBook1, Cell cellWorkBook2) {
-        return (cellWorkBook1.getCellStyle().getFillForegroundColorColor() != null)
-                && (cellWorkBook2.getCellStyle().getFillForegroundColorColor() == null);
-    }
-
     /**
      * Checks if cell fill pattern matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell fill pattern matches
      */
-    private boolean isCellFillPatternMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        return cellWorkBook1.getCellStyle().getFillPattern() != cellWorkBook2
-                .getCellStyle().getFillPattern();
+    private void isCellFillPatternMatches(Locator loc1, Locator loc2) {
+        // TOOO: Check for NPE
+        short fill1 = loc1.cell.getCellStyle().getFillPattern();
+        short fill2 = loc2.cell.getCellStyle().getFillPattern();
+        if (fill1 != fill2) {
+            addMessage(loc1, loc2,
+                "Cell Fill pattern does not Match ::",
+                Short.toString(fill1),
+                Short.toString(fill2)
+            );
+        }
     }
 
     /**
      * Checks if cell font bold matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell font bold matches
      */
-    private boolean isCellFontBoldMatches(Cell cellWorkBook1, Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return ((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()
-                    .getBold() != ((XSSFCellStyle) cellWorkBook2.getCellStyle())
-                    .getFont().getBold();
-        } else {
-            return false;
+    private void isCellFontBoldMatches(Locator loc1, Locator loc2) {
+        if (!(loc1.cell instanceof XSSFCell)) return;
+        boolean b1 = ((XSSFCell)loc1.cell).getCellStyle().getFont().getBold();
+        boolean b2 = ((XSSFCell)loc2.cell).getCellStyle().getFont().getBold();
+        if (b1 != b2) {
+            addMessage(loc1, loc2,
+                CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH,
+                (b1 ? "" : "NOT ")+"BOLD",
+                (b2 ? "" : "NOT ")+"BOLD"
+            );
         }
-
     }
 
     /**
      * Checks if cell font family matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell font family matches
      */
-    private boolean isCellFontFamilyMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return !(((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()
-                    .getFontName().equals(((XSSFCellStyle) cellWorkBook2
-                    .getCellStyle()).getFont().getFontName()));
-        } else {
-            return false;
+    private void isCellFontFamilyMatches(Locator loc1, Locator loc2) {
+        // TODO: Check for NPEs
+        if (!(loc1.cell instanceof XSSFCell)) return;
+        String family1 = ((XSSFCell)loc1.cell).getCellStyle().getFont().getFontName();
+        String family2 = ((XSSFCell)loc2.cell).getCellStyle().getFont().getFontName();
+        if (!family1.equals(family2)) {
+            addMessage(loc1, loc2, "Cell Font Family does not Match ::", family1, family2);
         }
     }
 
     /**
      * Checks if cell font italics matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell font italics matches
      */
-    private boolean isCellFontItalicsMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return ((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()
-                    .getItalic() != ((XSSFCellStyle) cellWorkBook2
-                    .getCellStyle()).getFont().getItalic();
-        } else {
-            return false;
+    private void isCellFontItalicsMatches(Locator loc1, Locator loc2) {
+        if (!(loc1.cell instanceof XSSFCell)) return;
+        boolean b1 = ((XSSFCell)loc1.cell).getCellStyle().getFont().getItalic();
+        boolean b2 = ((XSSFCell)loc2.cell).getCellStyle().getFont().getItalic();
+        if (b1 != b2) {
+            addMessage(loc1, loc2,
+                CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH,
+                (b1 ? "" : "NOT ")+"ITALICS",
+                (b2 ? "" : "NOT ")+"ITALICS"
+            );
         }
-
     }
 
     /**
      * Checks if cell font size matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell font size matches
      */
-    private boolean isCellFontSizeMatches(Cell cellWorkBook1, Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return ((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()
-                    .getFontHeightInPoints() != ((XSSFCellStyle) cellWorkBook2
-                    .getCellStyle()).getFont().getFontHeightInPoints();
-        } else {
-            return false;
+    private void isCellFontSizeMatches(Locator loc1, Locator loc2) {
+        if (!(loc1.cell instanceof XSSFCell)) return;
+        short size1 = ((XSSFCell)loc1.cell).getCellStyle().getFont().getFontHeightInPoints();
+        short size2 = ((XSSFCell)loc2.cell).getCellStyle().getFont().getFontHeightInPoints();
+        if (size1 != size2) {
+            addMessage(loc1, loc2,
+                "Cell Font Size does not Match ::",
+                Short.toString(size1),
+                Short.toString(size2)
+            );
         }
-
     }
 
     /**
      * Checks if cell hidden matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell hidden matches
      */
-    private boolean isCellHiddenMatches(Cell cellWorkBook1, Cell cellWorkBook2) {
-        return cellWorkBook1.getCellStyle().getHidden() != cellWorkBook2
-                .getCellStyle().getHidden();
+    private void isCellHiddenMatches(Locator loc1, Locator loc2) {
+        boolean b1 = loc1.cell.getCellStyle().getHidden();
+        boolean b2 = loc1.cell.getCellStyle().getHidden();
+        if (b1 != b2) {
+            addMessage(loc1, loc2,
+                "Cell Visibility does not Match ::",
+                (b1 ? "" : "NOT ")+"HIDDEN",
+                (b2 ? "" : "NOT ")+"HIDDEN"
+            );
+        }
     }
 
     /**
      * Checks if cell locked matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell locked matches
      */
-    private boolean isCellLockedMatches(Cell cellWorkBook1, Cell cellWorkBook2) {
-        return cellWorkBook1.getCellStyle().getLocked() != cellWorkBook2
-                .getCellStyle().getLocked();
+    private void isCellLockedMatches(Locator loc1, Locator loc2) {
+        boolean b1 = loc1.cell.getCellStyle().getLocked();
+        boolean b2 = loc1.cell.getCellStyle().getLocked();
+        if (b1 != b2) {
+            addMessage(loc1, loc2,
+                    "Cell Protection does not Match ::",
+                (b1 ? "" : "NOT ")+"LOCKED",
+                (b2 ? "" : "NOT ")+"LOCKED"
+            );
+        }
     }
 
     /**
      * Checks if cell type matches.
-     *
-     * @param cellWorkBook1
-     *            the cell work book1
-     * @param cellWorkBook2
-     *            the cell work book2
-     * @return true, if cell type matches
      */
-    private boolean isCellTypeMatches(Cell cellWorkBook1, Cell cellWorkBook2) {
-        return !(cellWorkBook1.getCellType() == cellWorkBook2.getCellType());
+    private boolean isCellTypeMatches(Locator loc1, Locator loc2) {
+        int type1 = loc1.cell.getCellType();
+        int type2 = loc2.cell.getCellType();
+        if (type1 == type2) return true;
+        addMessage(loc1, loc2,
+            "Cell Data-Type does not Match in :: ",
+            Integer.toString(type1),
+            Integer.toString(type2)
+        );
+        return false;
     }
 
     /**
@@ -1242,107 +596,17 @@ public class ExcelComparator {
      *            the cell work book2
      * @return true, if cell under line matches
      */
-    private boolean isCellUnderLineMatches(Cell cellWorkBook1,
-            Cell cellWorkBook2) {
-        if (cellWorkBook1.getCellStyle() instanceof XSSFCellStyle) {
-            return ((XSSFCellStyle) cellWorkBook1.getCellStyle()).getFont()
-                    .getUnderline() != ((XSSFCellStyle) cellWorkBook2
-                    .getCellStyle()).getFont().getUnderline();
-        } else {
-            return false;
+    private void isCellUnderLineMatches(Locator loc1, Locator loc2) {
+        // TOOO: distinguish underline type
+        if (!(loc1.cell instanceof XSSFCell)) return;
+        byte b1 = ((XSSFCell)loc1.cell).getCellStyle().getFont().getUnderline();
+        byte b2 = ((XSSFCell)loc2.cell).getCellStyle().getFont().getUnderline();
+        if (b1 != b2) {
+            addMessage(loc1, loc2,
+                CELL_FONT_ATTRIBUTES_DOES_NOT_MATCH,
+                (b1 == 1 ? "" : "NOT ")+"UNDERLINE",
+                (b2 == 1 ? "" : "NOT ")+"UNDERLINE"
+            );
         }
-
     }
-
-    /**
-     * Checks if name of sheet matches.
-     *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @param i
-     *            the i
-     * @return true, if name of sheet matches
-     */
-    private boolean isNameOfSheetMatches(Workbook workbook1,
-            Workbook workbook2, int i) {
-        if (workbook2.getNumberOfSheets() > i) {
-            return !(workbook1.getSheetName(i)
-                    .equals(workbook2.getSheetName(i)));
-        } else {
-            return true;
-        }
-
-    }
-
-    /**
-     * Checks if number of columns matches.
-     *
-     * @param sheetWorkBook1
-     *            the sheet work book1
-     * @param sheetWorkBook2
-     *            the sheet work book2
-     * @return true, if number of columns matches
-     */
-    private boolean isNumberOfColumnsMatches(Sheet sheetWorkBook1,
-            Sheet sheetWorkBook2) {
-        if (sheetWorkBook2 != null) {
-            return !(sheetWorkBook1.getRow(0).getLastCellNum() == sheetWorkBook2
-                    .getRow(0).getLastCellNum());
-        } else {
-            return true;
-        }
-
-    }
-
-    /**
-     * Checks if number of rows matches.
-     *
-     * @param sheetWorkBook1
-     *            the sheet work book1
-     * @param sheetWorkBook2
-     *            the sheet work book2
-     * @return true, if number of rows matches
-     */
-    private boolean isNumberOfRowsMatches(Sheet sheetWorkBook1,
-            Sheet sheetWorkBook2) {
-        if (sheetWorkBook2 != null) {
-            return !(sheetWorkBook1.getPhysicalNumberOfRows() == sheetWorkBook2
-                    .getPhysicalNumberOfRows());
-        } else {
-            return true;
-        }
-
-    }
-
-    /**
-     * Checks if number of sheets matches.
-     *
-     * @param workbook1
-     *            the workbook1
-     * @param workbook2
-     *            the workbook2
-     * @return true, if number of sheets matches
-     */
-    private boolean isNumberOfSheetsMatches(Workbook workbook1,
-            Workbook workbook2) {
-        return !(workbook1.getNumberOfSheets() == workbook2.getNumberOfSheets());
-    }
-
-    private boolean isWorkBookEmpty(Sheet sheetWorkBook1, Sheet sheetWorkBook2) {
-        if (sheetWorkBook2 != null) {
-            return !((null == sheetWorkBook1.getRow(0)) || (null == sheetWorkBook2
-                    .getRow(0)));
-        } else {
-            return true;
-        }
-
-    }
-
-}
-
-class ExcelFileDifference {
-    boolean isDifferenceFound;
-    List<String> listOfDifferences;
-}
+}
\ No newline at end of file

Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java?rev=1702773&r1=1702772&r2=1702773&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java Sun Sep 13 12:36:56 2015
@@ -102,16 +102,6 @@ public class XLSX2CSV {
          */
         private ReadOnlySharedStringsTable sharedStringsTable;
 
-        /**
-         * Destination for data
-         */
-        private final PrintStream output;
-
-        /**
-         * Number of columns to read starting with leftmost
-         */
-        private final int minColumnCount;
-
         // Set when V start element is seen
         private boolean vIsOpen;
 
@@ -141,13 +131,9 @@ public class XLSX2CSV {
          */
         public MyXSSFSheetHandler(
                 StylesTable styles,
-                ReadOnlySharedStringsTable strings,
-                int cols,
-                PrintStream target) {
+                ReadOnlySharedStringsTable strings) {
             this.stylesTable = styles;
             this.sharedStringsTable = strings;
-            this.minColumnCount = cols;
-            this.output = target;
             this.value = new StringBuffer();
             this.nextDataType = xssfDataType.NUMBER;
             this.formatter = new DataFormatter();
@@ -201,7 +187,8 @@ public class XLSX2CSV {
                     if (cellStyleStr != null) {
                         int styleIndex = Integer.parseInt(cellStyleStr);
                         style = stylesTable.getStyleAt(styleIndex);
-                    } else if (stylesTable.getNumCellStyles() > 0) {
+                    }
+                    if (style == null && stylesTable.getNumCellStyles() > 0) {
                         style = stylesTable.getStyleAt(0);
                     }
                     if (style != null) {
@@ -299,7 +286,7 @@ public class XLSX2CSV {
                     if (lastColumnNumber == -1) {
                         lastColumnNumber = 0;
                     }
-                    for (int i = lastColumnNumber; i < (this.minColumnCount); i++) {
+                    for (int i = lastColumnNumber; i < minColumns; i++) {
                         output.print(',');
                     }
                 }
@@ -340,9 +327,17 @@ public class XLSX2CSV {
 
     ///////////////////////////////////////
 
-    private OPCPackage xlsxPackage;
-    private int minColumns;
-    private PrintStream output;
+    private final OPCPackage xlsxPackage;
+
+    /**
+     * Number of columns to read starting with leftmost
+     */
+    private final int minColumns;
+
+    /**
+     * Destination for data
+     */
+    private final PrintStream output;
 
     /**
      * Creates a new XLSX -> CSV converter
@@ -375,7 +370,7 @@ public class XLSX2CSV {
         SAXParserFactory saxFactory = SAXParserFactory.newInstance();
         SAXParser saxParser = saxFactory.newSAXParser();
         XMLReader sheetParser = saxParser.getXMLReader();
-        ContentHandler handler = new MyXSSFSheetHandler(styles, strings, this.minColumns, this.output);
+        ContentHandler handler = new MyXSSFSheetHandler(styles, strings);
         sheetParser.setContentHandler(handler);
         sheetParser.parse(sheetSource);
     }
@@ -428,6 +423,7 @@ public class XLSX2CSV {
         OPCPackage p = OPCPackage.open(xlsxFile.getPath(), PackageAccess.READ);
 		XLSX2CSV xlsx2csv = new XLSX2CSV(p, System.out, minColumns);
 		xlsx2csv.process();
+		p.close();
 	}
 
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java?rev=1702773&r1=1702772&r2=1702773&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java Sun Sep 13 12:36:56 2015
@@ -83,13 +83,13 @@ public final class UnknownRecord extends
     public UnknownRecord(RecordInputStream in) {
         _sid = in.getSid();
         _rawData = in.readRemainder();
-        if (false && getBiffName(_sid) == null) {
-            // unknown sids in the range 0x0004-0x0013 are probably 'sub-records' of ObjectRecord
-            // those sids are in a different number space.
-            // TODO - put unknown OBJ sub-records in a different class
-            System.out.println("Unknown record 0x" + 
-                               Integer.toHexString(_sid).toUpperCase(Locale.ROOT));
-        }
+//        if (false && getBiffName(_sid) == null) {
+//            // unknown sids in the range 0x0004-0x0013 are probably 'sub-records' of ObjectRecord
+//            // those sids are in a different number space.
+//            // TODO - put unknown OBJ sub-records in a different class
+//            System.out.println("Unknown record 0x" + 
+//                               Integer.toHexString(_sid).toUpperCase(Locale.ROOT));
+//        }
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java?rev=1702773&r1=1702772&r2=1702773&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java Sun Sep 13 12:36:56 2015
@@ -211,9 +211,6 @@ public class XWPFFootnote implements Ite
             return null;
         }
         XWPFTableRow tableRow = table.getRow(row);
-        if (row == null) {
-            return null;
-        }
         return tableRow.getTableCell(cell);
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java?rev=1702773&r1=1702772&r2=1702773&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java Sun Sep 13 12:36:56 2015
@@ -139,7 +139,6 @@ public abstract class XWPFHeaderFooter e
             }
         }
 
-        List<XWPFTable> tables = getTables();
         for (int i = 0; i < tables.size(); i++) {
             String text = tables.get(i).getText();
             if (text != null && text.length() > 0) {
@@ -505,9 +504,6 @@ public abstract class XWPFHeaderFooter e
             return null;
         }
         XWPFTableRow tableRow = table.getRow(row);
-        if (row == null) {
-            return null;
-        }
         return tableRow.getTableCell(cell);
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java?rev=1702773&r1=1702772&r2=1702773&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java Sun Sep 13 12:36:56 2015
@@ -205,6 +205,10 @@ public class XWPFSettings extends POIXML
         } else {
             final STCryptProv.Enum providerType;
             final int sid;
+            if (hashAlgo == null) {
+                hashAlgo = HashAlgorithm.sha1;
+            }
+            
             switch (hashAlgo) {
                 case md2:
                     providerType = STCryptProv.RSA_FULL;
@@ -247,8 +251,6 @@ public class XWPFSettings extends POIXML
             // iteration's result as the input for the next iteration).
             int spinCount = 100000;
 
-            if (hashAlgo == null) hashAlgo = HashAlgorithm.sha1;
-
             String legacyHash = CryptoFunctions.xorHashPasswordReversed(password);
             // Implementation Notes List:
             // --> In this third stage, the reversed byte order legacy hash from the second stage shall



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org