public boolean newSection(Row row, PageSection nextSection) { for (PageForm form : nextSection.getPageForms()) { FormDisplayCell[][] cellGrid = form.getCellGrid(); for (FormDisplayCell[] line : cellGrid) { int colIdx = 0; for (FormDisplayCell cell : line) { if (null != cell) { // System.out.println("Model: '" + cell.getCellContents() + "' Spreadsheet: '" + // row.getCell(colIdx) + "'"); switch (cell.getCellType()) { case EMPTY: colIdx++; break; case COL_HEADING: Cell spreadsheetCell = row.getCell(colIdx); // Check that the spreadsheet cell content is the same as the model. if (null == spreadsheetCell) { // The spreadsheetCell can be null as long as there is nothing in the model cell. if (!cell.getCellContents().isEmpty()) { return false; } } else { try { if (!cell.getCellContents().equals(spreadsheetCell.getStringCellValue())) { // The next section and the current row are not the same. // System.out.println("Not a new section"); return false; } } catch (Exception e) { // System.out.println("Not a new section (not a String cell)"); return false; } } colIdx++; break; case ROW_HEADING_NON_REPEAT: case ROW_HEADING: case CALC: case COPYCELL: case INPUT: colIdx++; break; } } } } } System.out.println("Is a new section at row " + row.getRowNum() + 1); return true; }
public Section(PageSection pageSection) { this.itemCodeColumn = pageSection.getItemCodeColumn(); }