List of usage examples for org.apache.poi.ss.usermodel Row getRowNum
int getRowNum();
From source file:regression.data.GenerateLinearData.java
public Function testDataFromFile(File file, JTextArea output) throws FileNotFoundException, IOException, InvalidFormatException { FileInputStream excelFile = new FileInputStream(file); XSSFWorkbook workbook = new XSSFWorkbook(file); XSSFSheet firstSheet = workbook.getSheetAt(0); Iterator<Row> rowIterator = firstSheet.iterator(); List<Point> points = new ArrayList<>(); Function function = getLastSavedFunction(); output.append("Dla Funkcji:y=x" + function.getFactor().get(0) + "+" + function.getFreeFactor() + " Wartoci testowe przyjmuj" + "\n"); while (rowIterator.hasNext()) { Row row = rowIterator.next(); Cell firstCell = row.getCell(row.getFirstCellNum()); if (firstCell.getCellType() == Cell.CELL_TYPE_NUMERIC) { try { Double score = countFunction(function, firstCell.getNumericCellValue()); this.points.add(new Point(firstCell.getNumericCellValue(), score)); output.append("Dla x=" + firstCell.getNumericCellValue() + " y=" + score + "\n"); } catch (Exception e) { System.err.println("Cannot convert data in row: " + row.getRowNum()); }/* w ww . jav a 2 s.co m*/ } } return function; }
From source file:regression.data.GenerateLinearData.java
/** * Read data from excel/*from w ww.j a v a 2s . c o m*/ * * @param file * @throws FileNotFoundException * @throws IOException * @throws InvalidFormatException */ public List<Point> getExcelDataSet(File file) throws FileNotFoundException, IOException, InvalidFormatException { FileInputStream excelFile = new FileInputStream(file); XSSFWorkbook workbook = new XSSFWorkbook(file); XSSFSheet firstSheet = workbook.getSheetAt(0); Iterator<Row> rowIterator = firstSheet.iterator(); List<Point> points = new ArrayList<>(); while (rowIterator.hasNext()) { Row row = rowIterator.next(); Cell firstCell = row.getCell(row.getFirstCellNum()); Cell secondCell = row.getCell(row.getFirstCellNum() + 1); // if (secondCell != null) { if ((firstCell.getCellType() == Cell.CELL_TYPE_NUMERIC && secondCell.getCellType() == Cell.CELL_TYPE_NUMERIC)) { try { points.add(new Point(firstCell.getNumericCellValue(), secondCell.getNumericCellValue())); } catch (Exception e) { System.err.println("Cannot convert data in row: " + row.getRowNum()); } } } //else { // if (firstCell.getCellType() == Cell.CELL_TYPE_NUMERIC) { // try { // points.add(new Point(firstCell.getNumericCellValue(), 0.0)); // } catch (Exception e) { // System.err.println("Cannot convert data in row: " + row.getRowNum()); // } // } // } // } return points; }
From source file:regression.gui.MainWindow.java
void createWekaFile(String pathToNewWekaFile, File fileExcel) { try {/*from w w w .jav a2s.c om*/ File wekaFile = new File(pathToNewWekaFile); XSSFWorkbook workbook = new XSSFWorkbook(fileExcel); XSSFSheet firstSheet = workbook.getSheetAt(0); Iterator<Row> rowIterator = firstSheet.iterator(); PrintWriter writer = new PrintWriter(wekaFile); writer.println("@RELATION logistic"); writer.println("@ATTRIBUTE x NUMERIC"); writer.println("@ATTRIBUTE class {1,0}"); writer.println("@DATA"); while (rowIterator.hasNext()) { Row row = rowIterator.next(); Cell firstCell = row.getCell(row.getFirstCellNum()); Cell secondCell = row.getCell(row.getFirstCellNum() + 1); if (firstCell.getCellType() == Cell.CELL_TYPE_NUMERIC && secondCell.getCellType() == Cell.CELL_TYPE_NUMERIC) { try { writer.println( firstCell.getNumericCellValue() + "," + (int) secondCell.getNumericCellValue()); } catch (Exception e) { System.err.println("Cannot convert data in row: " + row.getRowNum()); } } } writer.close(); } catch (Exception ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ro.dabuno.office.integration.Xlsx2Word.java
public static void main(String[] args) throws Exception { log.info("starting app"); // Workbook wb = new XSSFWorkbook(new FileInputStream(args[0])); Workbook wb = new XSSFWorkbook(new FileInputStream("office-files/Input.xlsx")); DataFormatter formatter = new DataFormatter(); for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i);/*from w w w .j ava 2 s . c om*/ System.out.println(wb.getSheetName(i)); int j = 4; for (Row row : sheet) { System.out.println("rownum: " + row.getRowNum()); for (Cell cell : row) { CellReference cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex()); System.out.print(cellRef.formatAsString()); System.out.print(" - "); // get the text that appears in the cell by getting the cell value and applying any data formats (Date, 0.00, 1.23e9, $1.23, etc) String text = formatter.formatCellValue(cell); System.out.println(text); System.out.println("------------"); // Alternatively, get the value and format it yourself switch (cell.getCellTypeEnum()) { case STRING: System.out.println(cell.getRichStringCellValue().getString()); break; case NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { System.out.println(cell.getDateCellValue()); } else { System.out.print(cellRef.formatAsString()); System.out.print(" - "); System.out.println((long) cell.getNumericCellValue()); } break; case BOOLEAN: System.out.println(cell.getBooleanCellValue()); break; case FORMULA: System.out.println(cell.getCellFormula()); break; case BLANK: System.out.println(); break; default: System.out.println(); } } j--; if (j == 0) { break; } } } XWPFDocument doc = new XWPFDocument(); XWPFParagraph p0 = doc.createParagraph(); XWPFRun r0 = p0.createRun(); r0.setBold(false); r0.setText("Domnule"); XWPFRun r00 = p0.createRun(); r00.setBold(true); r00.setText(" Ionescu Ion"); FileOutputStream out = new FileOutputStream("out/xlsx2word.docx"); doc.write(out); out.close(); }
From source file:rpt.GUI.ProgramStrategist.CyclePlans.CompareDialogController.java
private int writeRow(Workbook wb, Sheet sheet, Row row, TableVariant variant, Map<String, Map<String, String>> diffList, Boolean colorChanges, Boolean addOldSOP) { //Used for placing comment at the right position CreationHelper factory = wb.getCreationHelper(); Drawing drawing = sheet.createDrawingPatriarch(); ClientAnchor anchor = factory.createClientAnchor(); //Create new style XSSFCellStyle styleRed = (XSSFCellStyle) wb.createCellStyle(); XSSFCellStyle styleBlack = (XSSFCellStyle) wb.createCellStyle(); XSSFFont fontRed = (XSSFFont) wb.createFont(); fontRed.setColor(new XSSFColor(new java.awt.Color(255, 0, 0))); XSSFFont fontBlack = (XSSFFont) wb.createFont(); fontBlack.setColor(new XSSFColor(new java.awt.Color(0, 0, 0))); styleRed.setFont(fontRed);//ww w. j av a 2 s . c o m styleBlack.setFont(fontBlack); //xEtract differences to highlight Map<String, String> differences; if (diffList != null) { differences = diffList.get(variant.getVariantID()); } else { differences = new HashMap<String, String>(); } //Start with column 0 int cols = 0; //Create string with columns to print String[] columns = { "Plant", "Platform", "Vehicle", "Propulsion", "Denomination", "Fuel", "EngineFamily", "Generation", "EngineCode", "Displacement", "EnginePower", "ElMotorPower", "Torque", "TorqueOverBoost", "GearboxType", "Gears", "Gearbox", "Driveline", "TransmissionCode", "CertGroup", "EmissionClass", "StartOfProd", "EndOfProd" }; Cell cell; for (int i = 0; i < columns.length; i++) { cell = row.createCell(i); if (differences.containsKey(columns[i])) { cell.setCellStyle(styleRed); // position the comment anchor.setCol1(cell.getColumnIndex()); anchor.setCol2(cell.getColumnIndex() + 1); anchor.setRow1(row.getRowNum()); anchor.setRow2(row.getRowNum() + 3); // Create the comment and set the text+author Comment comment = drawing.createCellComment(anchor); RichTextString str = factory.createRichTextString(differences.get(columns[i])); comment.setString(str); comment.setAuthor("RPT"); // Assign the comment to the cell cell.setCellComment(comment); } else { cell.setCellStyle(styleBlack); } cell.setCellValue(variant.getValue(columns[i])); cols++; } if (addOldSOP) { cell = row.createCell(23); cell.setCellValue(variant.getOldSOP()); cols++; } if (addOldSOP) { cell = row.createCell(24); cell.setCellValue(variant.getOldEOP()); cols++; } return cols; }
From source file:ru.codemine.ccms.sales.domino.DominoSalesLoader.java
License:Open Source License
private Map<LocalDate, Map<String, Sales>> getSalesMap() { File path = new File(settingsService.getStorageEmailPath()); FilenameFilter filter = new EndsWithFilenameFilter(".xls", EndsWithFilenameFilter.NEVER); Map<LocalDate, Map<String, Sales>> result = new HashMap(); for (File file : path.listFiles(filter)) { try {//from w w w . ja v a 2 s. c o m log.info(" : " + file.getName()); FileInputStream fs = new FileInputStream(file); HSSFWorkbook workbook = new HSSFWorkbook(fs); HSSFSheet sheet = workbook.getSheetAt(0); boolean dateFound = false; boolean colFound = false; Integer colNumber = 0; LocalDate fileDate = null; Map<String, Sales> parsedFileMap = new HashMap(); for (Row row : sheet) { Cell firstCell = row.getCell(0); // // ? // if (firstCell.getCellType() == Cell.CELL_TYPE_STRING && firstCell.getStringCellValue() .startsWith(" ")) { String bothDatesStr = firstCell.getStringCellValue() .replace(" ? ", ""); String[] datesStr = bothDatesStr.split(" "); DateTimeFormatter formatter = DateTimeFormat.forPattern("dd.MM.YYYY"); LocalDate startDate = formatter.parseLocalDate(datesStr[0]); LocalDate endDate = formatter.parseLocalDate(datesStr[1]); if (startDate != null && startDate.isEqual(endDate)) { dateFound = true; fileDate = startDate; log.info(" : " + fileDate); } } // // ? ? ? ? ? // else if (firstCell.getCellType() == Cell.CELL_TYPE_STRING && firstCell.getStringCellValue().startsWith(" /")) { for (Cell headersCell : row) { if (headersCell.getCellType() == Cell.CELL_TYPE_STRING && headersCell .getStringCellValue().startsWith(" ??")) { colFound = true; colNumber = headersCell.getColumnIndex(); log.info(" : " + colNumber); } } } // // ? ? // else if (dateFound && colFound && firstCell.getCellType() == Cell.CELL_TYPE_STRING && firstCell.getStringCellValue().startsWith(":")) { Sales sale = new Sales(); // ? String namesStr = firstCell.getStringCellValue().replace(": ", ""); String delimiter = " - "; if (namesStr.indexOf(delimiter) > 0 && namesStr.indexOf(delimiter) != namesStr.lastIndexOf(delimiter)) { String name = namesStr.substring(namesStr.indexOf(delimiter) + delimiter.length(), namesStr.lastIndexOf(delimiter)); // ? boolean shopFinished = false; int rcrd = 1; int cashb_rcrd = 0; while (!shopFinished) { Row r = sheet.getRow(row.getRowNum() + rcrd); if (r.getCell(0).getCellType() == Cell.CELL_TYPE_NUMERIC) // ? ? { Double val = r.getCell(colNumber).getNumericCellValue(); //log.debug("i is: " + i + ", val is: " + val); if (val > 0) sale.setValue(sale.getValue() + val); // else { sale.setCashback(sale.getCashback() - val); // cashb_rcrd++; } } else if (r.getCell(0).getStringCellValue().startsWith(" :")) { //log.debug("finished shop record, i is: " + i); sale.setChequeCount(rcrd - cashb_rcrd - 1); shopFinished = true; } rcrd++; } parsedFileMap.put(name, sale); //Double value = row.getCell(colNumber).getNumericCellValue(); //parsedFileMap.put(name, value); //log.debug("Recieved file map: " + parsedFileMap); } } } // foreach row in sheet if (dateFound && colFound) { result.put(fileDate, parsedFileMap); log.info("...ok"); Files.delete(file.toPath()); } else { if (!dateFound) { log.warn(" " + file.getName()); } if (!colFound) { log.warn(" ? " + file.getName()); } log.error("? " + file.getName()); } } catch (Exception e) { //e.printStackTrace(); log.error("? , : " + e.getMessage()); } } // foreach file in path return result; }
From source file:ru.spb.nicetu.tableviewer.server.XlsToHtml.java
License:Apache License
private void printSheetContent(Sheet sheet) { printColumnHeads();/*from w w w . j a v a 2 s. c o m*/ out.format("<tbody>%n"); Iterator<Row> rows = sheet.rowIterator(); int lastNum = -1; while (rows.hasNext()) { Row row = rows.next(); int curNum = row.getRowNum(); if (curNum - lastNum > 1) { for (int i = lastNum + 2; i <= curNum; i++) { out.format(" <tr>%n"); out.format(" <td class=%s>%d</td>%n", ROW_HEAD_CLASS, i); out.format(" <td colspan=%d style=\"%s\"> </td>%n", (endColumn - firstColumn + 1), styleSimpleContents(null, false)); out.format(" </tr>%n"); } } lastNum = curNum; out.format(" <tr>%n"); out.format(" <td class=%s>%d</td>%n", ROW_HEAD_CLASS, row.getRowNum() + 1); for (int i = firstColumn; i < endColumn; i++) { String content = " "; String attrs = ""; CellStyle style = null; boolean isNumeric = false; if (i >= row.getFirstCellNum() && i < row.getLastCellNum()) { Cell cell = row.getCell(i); if (cell != null) { style = cell.getCellStyle(); attrs = tagStyle(cell, style); CellFormat cf = CellFormat.getInstance(style.getDataFormatString()); CellFormatResult result = cf.apply(cell); content = result.text; if (content != null && !content.equals("") && (cell.getCellType() == Cell.CELL_TYPE_NUMERIC || cell.getCellType() == Cell.CELL_TYPE_FORMULA && cell.getCachedFormulaResultType() == Cell.CELL_TYPE_NUMERIC)) { if (DateUtil.isCellDateFormatted(cell)) { // Date if ("mmm-yy".equals(style.getDataFormatString())) { SimpleDateFormat sdfRus = new SimpleDateFormat("MMM.yy"); content = sdfRus.format(cell.getDateCellValue()); } else if ("h:mm".equals(style.getDataFormatString())) { SimpleDateFormat sdfRus = new SimpleDateFormat("HH:mm"); content = sdfRus.format(cell.getDateCellValue()); } else if (style.getDataFormatString() != null && style.getDataFormatString().contains("mm")) { SimpleDateFormat sdfRus = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); content = sdfRus.format(cell.getDateCellValue()); } else { SimpleDateFormat sdfRus = new SimpleDateFormat("dd.MM.yyyy"); content = sdfRus.format(cell.getDateCellValue()); } } else { // Number if ("- 0".equals(content.trim())) content = " "; else content = "<nobr>" + content.replace(",", " ").replace(".", ",") + "</nobr>"; isNumeric = true; } } if (content == null || content.equals("")) content = " "; } } boolean isInRangeNotFirst = false; for (int j = 0; j < sheet.getNumMergedRegions(); j++) { CellRangeAddress rangeAddress = sheet.getMergedRegion(j); if (row.getRowNum() == rangeAddress.getFirstRow() && i == rangeAddress.getFirstColumn()) { if (rangeAddress.getLastRow() - row.getRowNum() > 0) attrs += " rowspan=" + (rangeAddress.getLastRow() - row.getRowNum() + 1); if (rangeAddress.getLastColumn() - i > 0) attrs += " colspan=" + (rangeAddress.getLastColumn() - i + 1); break; } else if (row.getRowNum() >= rangeAddress.getFirstRow() && row.getRowNum() <= rangeAddress.getLastRow() && i >= rangeAddress.getFirstColumn() && i <= rangeAddress.getLastColumn()) { isInRangeNotFirst = true; break; } } if (!isInRangeNotFirst) { out.format(" <td style=\"%s\" %s>%s</td>%n", styleSimpleContents(style, isNumeric), attrs, content); } } // columns out.format(" </tr>%n"); } // rows out.format("</tbody>%n"); }
From source file:se.nrm.dina.inventory.client.controller.ExcelFileHandler_1.java
private String getCatNumber(Row row) { Cell cell = row.getCell(obsTitleMap.get(CAT_NUM)); if (cell == null) { errorMsgs.add(CommonMessages.getInstance().buildMessage(row.getRowNum() + 1, CommonMessages.getInstance().INVALID_FILE_ON_ROW, CommonMessages.getInstance().CATALOGNUMEBR_IS_EMPTY)); return null; } else {// ww w. java 2s . c o m catNumber = (cell.getCellType() == Cell.CELL_TYPE_STRING) ? cell.getStringCellValue() : String.valueOf((int) cell.getNumericCellValue()); if (catNumber.equals("0")) { errorMsgs.add(CommonMessages.getInstance().buildMessage(row.getRowNum() + 1, CommonMessages.getInstance().INVALID_FILE_ON_ROW, CommonMessages.getInstance().CATALOGNUMEBR_IS_EMPTY)); return null; } if (catNumList.contains(catNumber)) { errorMsgs.add(CommonMessages.getInstance().buildMessage(String.valueOf(row.getRowNum() + 1), catNumber, CommonMessages.getInstance().INVALID_FILE_ON_ROW, CommonMessages.getInstance().CATALOGNUMBER, CommonMessages.getInstance().DUPLICATED)); return null; } if (!client.isCatalogNumeExistInDb(catNumber, COLLECTION_ID_DFILE)) { errorMsgs.add(CommonMessages.getInstance().buildMessage(String.valueOf(row.getRowNum() + 1), catNumber, CommonMessages.getInstance().INVALID_FILE_ON_ROW, CommonMessages.getInstance().CATALOGNUMBER, CommonMessages.getInstance().EXIST_IN_DB)); return null; } return catNumber; } }
From source file:se.nrm.dina.inventory.client.controller.ExcelFileHandler_1.java
private TaxaData buildTaxaData(Row row) { int taxonId = 0; int dyntaxaId = 0; String dyntaxa = null;/*from w w w .j av a 2 s . c o m*/ String dyntaxaGuid = null; Map<String, String> dyntaxaMap = new HashMap(); Cell cell = row.getCell(computedTaxonIndex); taxonname = getCellStringValue(cell); cell = row.getCell(genusIndex); genus = cell.getStringCellValue(); cell = row.getCell(speciesIndex); species = cell.getStringCellValue(); if (taxonname == null || taxonname.isEmpty()) { errorMsgs.add(CommonMessages.getInstance().TAXON_COMPUTED_IS_EMPTY); return null; } else if (!taxonname.trim().equals((genus + " " + species).trim())) { errorMsgs .add("Row " + (row.getRowNum() + 1) + CommonMessages.getInstance().TAXON_COMPUTED_IS_INCORRECT); return null; } cell = row.getCell(authorIndex); author = getCellStringValue(cell); cell = row.getCell(notesIndex); notes = getCellStringValue(cell); cell = row.getCell(guidIndex); guid = getCellStringValue(cell); cell = row.getCell(sourceIndex); source = getCellStringValue(cell); if (source.equals("Dyntaxa") || (guid != null && guid.contains("dyntaxa"))) { if (!guid.isEmpty()) { if (guid.contains("://")) { dyntaxaId = Integer.parseInt(StringUtils.substringAfterLast(guid, "/")); } else if (guid.contains("urn:")) { dyntaxaId = Integer.parseInt(StringUtils.substringAfterLast(guid, ":")); int rowNumber = row.getRowNum() + 1; waringMsgs.add("Taxon on row number: " + rowNumber + " Taxon guid in taxonlist might be incorrect, please make sure it is right before continue."); } else { errorMsgs.add("Unable to read taxon id from guid in taxon list sheet"); return null; } dyntaxaMap = getTaxaByDyntaxaId(dyntaxaId); } if (dyntaxaMap.isEmpty()) { if (dyntaxaId < 6005095) { // dyntaxaMap = getTaxaByOldDyntaxaId(dyntaxaId); } else { int rowNumber = row.getRowNum() + 1; errorMsgs.add("Taxon on row number: " + rowNumber + " is not in database. "); return null; } if (dyntaxaMap == null) { int rowNumber = row.getRowNum() + 1; errorMsgs.add("Wrong guid or taxon not in database on row number: " + rowNumber + " in taxon list sheet. "); return null; } if (dyntaxaMap.isEmpty()) { errorMsgs.add(CommonMessages.getInstance().buildMessage(row.getRowNum() + 1, CommonMessages.getInstance().TAXON_ON_ROW, CommonMessages.getInstance().NOT_IN_DB)); return null; } else { taxonId = Integer.parseInt(dyntaxaMap.get("taxonId")); dyntaxa = dyntaxaMap.get("taxonName"); dyntaxaGuid = dyntaxaMap.get("guid"); return null; // return new TaxaData(taxonId, replaceSP(taxonname, dyntaxaDumpDate, false), guid, source, author, notes, "Synonym", dyntaxaId, dyntaxa, dyntaxaGuid); } } else { taxonId = Integer.parseInt(dyntaxaMap.get("taxonId")); dyntaxa = dyntaxaMap.get("taxonName"); dyntaxaGuid = dyntaxaMap.get("guid"); return null; // return new TaxaData(taxonId, replaceSP(taxonname, dyntaxaDumpDate, false), guid, source, author, notes, "Synonym", dyntaxaId, dyntaxa, dyntaxaGuid); } } else { if (isNameValid(taxonname)) { if (taxonname.contains("sp.")) { taxonname = (taxonname.replace("sp.", "")).trim(); } String type = "Synonym"; dyntaxaMap = client.getDyntaxaByName(taxonname, 11); if (dyntaxaMap.isEmpty()) { dyntaxaMap = client.getDyntaxaByName(genus, 11); type = "Parent"; } if (!dyntaxaMap.isEmpty()) { dyntaxaGuid = dyntaxaMap.get("guid"); taxonId = Integer.parseInt(dyntaxaMap.get("taxonId")); if (type.equals("Parent")) { dyntaxa = genus + " [" + dyntaxaGuid + "]"; } else { dyntaxa = getComputedTaxonNameAndGuid(taxonname, dyntaxaGuid); } } // if(!dyntaxaMap.isEmpty()) { // type = "Synonym"; // taxonId = Integer.parseInt(dyntaxaMap.get("taxonId")); // dyntaxaGuid = dyntaxaMap.get("guid"); // dyntaxa = getComputedTaxonNameAndGuid(taxonname, dyntaxaGuid); // } else { // dyntaxaMap = client.getDyntaxaByName(genus, 11); // if(!dyntaxaMap.isEmpty()) { // taxonId = Integer.parseInt(dyntaxaMap.get("taxonId")); // dyntaxa = dyntaxaMap.get("taxonName"); // dyntaxaGuid = dyntaxaMap.get("guid"); // } // } return null; // return new TaxaData(taxonId, replaceSP(taxonname, dyntaxaDumpDate, type.equals("Parent")), guid, source, author, notes, type, dyntaxaId, dyntaxa, dyntaxaGuid); } else { errorMsgs.add(CommonMessages.getInstance().buildMessage(row.getRowNum() + 1, CommonMessages.getInstance().INVALID_TAXON_NAME_ON_ROW, "")); return null; } } }
From source file:se.nrm.dina.inventory.client.controller.ExcelFileHandler_1.java
private ObservationData buildCollectionObjectData(Row row) { Cell cell = row.getCell(0);/*from w w w.j a v a 2 s. co m*/ genus = cell.getStringCellValue(); cell = row.getCell(getIndex(SPECIES, obsTitleMap)); species = getCellStringValue(cell); if (species == null || species.isEmpty()) { errorMsgs.add(CommonMessages.getInstance().buildMessage(row.getRowNum() + 1, CommonMessages.getInstance().INVALID_FILE_ON_ROW, CommonMessages.getInstance().MISSING_SPECIES)); return null; } else { computedNameMapKey = genus + " " + species; if (computedTaxaMap.containsKey(computedNameMapKey)) { computedName = computedTaxaMap.get(computedNameMapKey); } else { computedName = getComputedName(genus, species); computedTaxaMap.put(computedNameMapKey, computedName); } } cell = row.getCell(getIndex(DET_DATE, obsTitleMap)); detDate = getCellIntValue(cell); cell = row.getCell(getIndex(MALES, obsTitleMap)); numMales = getCellIntValue(cell); cell = row.getCell(getIndex(FEMALES, obsTitleMap)); numFemales = getCellIntValue(cell); if (fileType.equals(D_FILE)) { cell = row.getCell(getIndex(CAT_NUM, obsTitleMap)); catalognumber = getCellStringValue(cell); if (catalognumber == null || catalognumber.isEmpty()) { errorMsgs.add(CommonMessages.getInstance().buildMessage(row.getRowNum() + 1, CommonMessages.getInstance().INVALID_FILE_ON_ROW, CommonMessages.getInstance().MISSING_CATALOGNUMBER)); } } else { cell = row.getCell(getIndex(TOTAL, obsTitleMap)); total = (cell.getCellType() == Cell.CELL_TYPE_STRING) ? intParse(cell.getStringCellValue()) : (int) cell.getNumericCellValue(); } cell = row.getCell(getIndex(NOTES, obsTitleMap)); eventNotes = getCellStringValue(cell); cell = row.getCell(getIndex(TRAP_ID, obsTitleMap)); trapId = getCellIntValue(cell); cell = row.getCell(getIndex(EVENT_ID, obsTitleMap)); eventId = getCellIntValue(cell); if (obsTitleMap.containsKey(STORAGE)) { cell = row.getCell(getIndex(STORAGE, obsTitleMap)); } else if (obsTitleMap.containsKey(PLACED_STORAGE)) { cell = row.getCell(getIndex(PLACED_STORAGE, obsTitleMap)); } else { cell = null; } storage = getCellStringValue(cell); cell = row.getCell(getIndex(MEDIA, obsTitleMap)); media = getCellStringValue(cell); ceId = ceMap.get(eventId); ObservationData coData = new ObservationData(eventId, ceId, trapId, genus, species, computedName, catalognumber, storage, media, String.valueOf(detDate), eventNotes, numMales, numFemales, total); if (computedName == null) { coDataList.add(0, coData); errorMsgs.add(CommonMessages.getInstance().buildInvalidTaxonNotInTaxonListMessage(row.getRowNum() + 1, genus, species)); } else if (eventId == 0) { waringMsgs.add(CommonMessages.getInstance().buildMessage(row.getRowNum() + 1, "Row", CommonMessages.getInstance().MISSING_COLLECTINGEVENT)); coDataList.add(0, coData); } else { coDataList.add(coData); } return coData; }