List of usage examples for org.apache.poi.hssf.usermodel HSSFSheet getPhysicalNumberOfRows
@Override public int getPhysicalNumberOfRows()
From source file:com.concursive.connect.web.modules.plans.utils.AssignmentExcelImporter.java
License:Open Source License
/** * Description of the Method//from w w w. j ava 2 s.c om * * @param requirement Description of the Parameter * @param db Description of the Parameter * @param buffer Description of the Parameter * @return Description of the Return Value * @throws java.sql.SQLException Description of the Exception */ public static boolean parse(byte[] buffer, Requirement requirement, Connection db) throws SQLException { if (System.getProperty("DEBUG") != null) { System.out.println("AssignmentExcelImporter-> parseExcel"); } try { db.setAutoCommit(false); // stream the Excel Spreadsheet from the uploaded byte array POIFSFileSystem fs = new POIFSFileSystem(new ByteArrayInputStream(buffer)); HSSFWorkbook hssfworkbook = new HSSFWorkbook(fs); // get the first sheet HSSFSheet sheet = hssfworkbook.getSheetAt(0); // define objects for housing spreadsheet data HSSFRow currentRow = sheet.getRow(0); // parse each row, create and insert into a new requirement with a tree int rows = sheet.getPhysicalNumberOfRows(); if (System.getProperty("DEBUG") != null) { System.out.println("AssignmentExcelImporter-> Number of rows: " + rows); } // Columns int columnHeader = -1; int columnMax = -1; boolean columnItemComplete = false; short itemColumn = -1; short priorityColumn = -1; short assignedToColumn = -1; short effortColumn = -1; short startColumn = -1; short endColumn = -1; // parse for (int r = 0; r < rows; r++) { currentRow = sheet.getRow(r); if (currentRow != null) { // Search for header if (columnHeader == -1) { int cells = currentRow.getPhysicalNumberOfCells(); for (short c = 0; c < cells; c++) { HSSFCell cell = currentRow.getCell(c); if (cell != null) { if ("Item".equals(getValue(cell))) { columnHeader = r; itemColumn = c; columnMax = c; } else if (itemColumn > -1 && !columnItemComplete && c > itemColumn) { if ("".equals(getValue(cell))) { columnMax = c; } else if (!"".equals(getValue(cell))) { columnItemComplete = true; } } if ("Priority".equals(getValue(cell))) { columnHeader = r; priorityColumn = c; } else if ("Assigned To".equals(getValue(cell))) { columnHeader = r; assignedToColumn = c; } else if ("Lead".equals(getValue(cell))) { columnHeader = r; assignedToColumn = c; } else if ("Effort".equals(getValue(cell))) { columnHeader = r; effortColumn = c; } else if ("Start".equals(getValue(cell))) { columnHeader = r; startColumn = c; } else if ("End".equals(getValue(cell))) { columnHeader = r; endColumn = c; } } } } // Process each column if (columnHeader > -1 && r > columnHeader) { boolean gotOne = false; Assignment assignment = new Assignment(); assignment.setProjectId(requirement.getProjectId()); assignment.setRequirementId(requirement.getId()); // Activities and folders if (itemColumn > -1) { // Get the first indent level that has data for (short c = itemColumn; c <= columnMax; c++) { HSSFCell cell = currentRow.getCell(c); if (cell != null && !"".equals(getValue(cell))) { assignment.setRole(getValue(cell)); assignment.setIndent(c); gotOne = true; break; } } } if (gotOne) { // Priority if (priorityColumn > -1) { HSSFCell cell = currentRow.getCell(priorityColumn); if (cell != null) { assignment.setPriorityId(getValue(cell)); } } // Effort if (effortColumn > -1) { HSSFCell cell = currentRow.getCell(effortColumn); if (cell != null) { assignment.setEstimatedLoe(getValue(cell)); if (assignment.getEstimatedLoeTypeId() == -1) { assignment.setEstimatedLoeTypeId(2); } } } // Assigned To if (assignedToColumn > -1) { HSSFCell cell = currentRow.getCell(assignedToColumn); if (cell != null) { assignment.addUsers(getValue(cell)); } } // Start Date if (startColumn > -1) { HSSFCell cell = currentRow.getCell(startColumn); if (cell != null) { assignment.setEstStartDate(getDateValue(cell)); } } // Due Date if (endColumn > -1) { HSSFCell cell = currentRow.getCell(endColumn); if (cell != null) { assignment.setDueDate(getDateValue(cell)); } } assignment.setEnteredBy(requirement.getEnteredBy()); assignment.setModifiedBy(requirement.getModifiedBy()); assignment.setStatusId(1); // Make sure a valid priority is set if (assignment.getPriorityId() < 1 || assignment.getPriorityId() > 3) { assignment.setPriorityId(2); } // Make sure user is on team, before adding, else unset the field if (!assignment.hasValidTeam(db)) { assignment.getAssignedUserList().clear(); } // Insert the assignment assignment.insert(db); if (System.getProperty("DEBUG") != null) { System.out.println( "AssignmentExcelImporter-> Assignment Inserted: " + assignment.getId()); } } } } } db.commit(); } catch (Exception e) { db.rollback(); e.printStackTrace(System.out); return false; } finally { db.setAutoCommit(true); } return true; }
From source file:com.ctb.importdata.ImportSFDataProcessor.java
public static ArrayList<SalesForceLicenseData> readDataFromXLSFile(String fileName) { File sfDataFile = new File(fileName); FileInputStream fileInputStream = null; ArrayList<SalesForceLicenseData> sfLicenseDataList = null; SalesForceLicenseData sfld = null;/* www .ja v a2 s. co m*/ if (sfDataFile.exists()) { //System.out.println("Reading data from .xls file started."); logger.info("Reading data from .xls file : Started :: Timestamp >> " + new Date(System.currentTimeMillis())); try { //read the file in to stream fileInputStream = new FileInputStream(sfDataFile); //Create Workbook instance holding reference to .xls file HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream); //Get first/desired sheet from the workbook HSSFSheet sheet = workbook.getSheetAt(0); sfLicenseDataList = new ArrayList<SalesForceLicenseData>(); if (sheet != null) { int totalRows = sheet.getPhysicalNumberOfRows(); //System.out.println("Total no. of physical rows in file = "+ totalRows); logger.info("Total no. of physical rows in file = " + totalRows); Row headerRow = sheet.getRow(0); Cell headerCell; Cell dataCell; if (headerRow == null) { //System.out.println("No file header content found.") ; logger.info("No file header content found."); } else { int totalHeaderColumns = headerRow.getPhysicalNumberOfCells(); //System.out.println("Total no. of header cells = "+ totalHeaderColumns); logger.info("Total no. of header cells = " + totalHeaderColumns); for (int rowCtr = 1; rowCtr < totalRows; rowCtr++) { //System.out.println("Row No. >> "+rowCtr); Row dataRow = sheet.getRow(rowCtr); if (dataRow != null) { int totalRowColumns = dataRow.getPhysicalNumberOfCells(); //System.out.println("Total no. of current data row cells = "+ totalRowColumns); //logger.info("Total no. of current data row cells = "+ totalRowColumns); logger.info( "Row No. [" + rowCtr + "] :: Header Column Count = [" + totalHeaderColumns + "] :: Current Data Row Column Count = [" + totalRowColumns + "]"); //Discard dummy rows in spreadsheet if the count of row columns not equal to header columns if (totalHeaderColumns == totalRowColumns) { boolean isCustomerIdBlank = dataRow.getCell(0) .getCellType() == Cell.CELL_TYPE_BLANK ? true : false; boolean isOrgNodeIdBlank = dataRow.getCell(5) .getCellType() == Cell.CELL_TYPE_BLANK ? true : false; //System.out.println("isCustomerIdBlank >> "+isCustomerIdBlank+" :: isOrgNodeIdBlank >> "+isOrgNodeIdBlank); logger.info("Row No. [" + rowCtr + "] :: isCustomerIdBlank >> " + isCustomerIdBlank + " :: isOrgNodeIdBlank >> " + isOrgNodeIdBlank); //Condition to skip row for SF data object population if customer id or orgnode id is blank if (!isCustomerIdBlank && !isOrgNodeIdBlank) { sfld = new SalesForceLicenseData(); // For each row, loop through each column for (int colCtr = 0; colCtr < totalHeaderColumns; colCtr++) { //System.out.println("Column No. >> "+colCtr); headerCell = headerRow.getCell(colCtr); dataCell = dataRow.getCell(colCtr); if (dataCell != null) { //System.out.println("dataCell.getCellType() >> "+dataCell.getCellType()); switch (dataCell.getCellType()) { case Cell.CELL_TYPE_BOOLEAN: //Do nothing //System.out.println(dataCell.getBooleanCellValue()); break; case Cell.CELL_TYPE_NUMERIC: //System.out.println(dataCell.getNumericCellValue()); populateSFDataNumericColValue(sfld, dataCell, headerCell); break; case Cell.CELL_TYPE_STRING: //System.out.println(dataCell.getStringCellValue()); populateSFDataStrColValue(sfld, dataCell, headerCell); break; case Cell.CELL_TYPE_BLANK: populateSFDataBlankColValue(sfld, dataCell, headerCell); break; default: System.out.println(dataCell); break; } } } sfLicenseDataList.add(sfld); } } } } } } } catch (FileNotFoundException e) { logger.error("FileNotFoundException : occurred while procesing :: Filename >> [" + fileName + "]"); e.printStackTrace(); // unexpected } catch (IOException e) { logger.error("IOException : occurred while procesing :: Filename >> [" + fileName + "]"); e.printStackTrace(); } finally { try { if (fileInputStream != null) fileInputStream.close(); } catch (IOException e) { logger.error("IOException : occurred while closing file input stream."); e.printStackTrace(); } } //System.out.println("Reading data from .xls file completed."); logger.info("Reading data from .xls file : Completed :: Timestamp >> " + new Date(System.currentTimeMillis())); } else { //System.out.println("File does not exists"); logger.error("File does not exists :: Filename >> [" + fileName + "]"); } return sfLicenseDataList; }
From source file:com.dawg6.web.dhcalc.server.ExportExcel.java
License:Open Source License
private Cell createTableHeader(HSSFSheet sheet, int col, String label) { int n = sheet.getPhysicalNumberOfRows(); Row row = null;/*w w w . jav a2 s . co m*/ if (n < 1) row = sheet.createRow(0); else row = sheet.getRow(0); Cell cell = row.createCell(col); cell.setCellValue(label); cell.setCellStyle(boldStyle); CellUtil.setAlignment(cell, sheet.getWorkbook(), CellStyle.ALIGN_CENTER); return cell; }
From source file:com.elbeesee.poink.transreptor.HSSFSheetToXML.java
License:Open Source License
public void onTransrept(INKFRequestContext aContext) throws Exception { IHSSFSheetRepresentation aIHSSFSheetRepresentation = (IHSSFSheetRepresentation) aContext .sourcePrimary(IHSSFSheetRepresentation.class); HSSFSheet vSheet = aIHSSFSheetRepresentation.getSheetReadOnly(); String vSheetName = vSheet.getSheetName(); StringBuilder vSheetXML = new StringBuilder(); vSheetXML.append("<sheet sheetName=\""); vSheetXML.append(XMLUtils.escape(vSheetName)); vSheetXML.append("\" sheetIndex=\""); vSheetXML.append(vSheet.getWorkbook().getSheetIndex(vSheetName)); vSheetXML.append("\" numRows=\""); vSheetXML.append(vSheet.getPhysicalNumberOfRows()); vSheetXML.append("\">"); // do the rows int i = 0;//from w w w . ja v a 2 s. c om for (Iterator<Row> vRowIterator = vSheet.rowIterator(); vRowIterator.hasNext();) { HSSFRow vHSSFRow = (HSSFRow) vRowIterator.next(); IHSSFRowRepresentation vHSSFRowRepresentation = new HSSFRowImplementation(vHSSFRow); String vRowXML = aContext.transrept(vHSSFRowRepresentation, String.class); vSheetXML.append(vRowXML); i = i + 1; } // vSheetXML.append("</sheet>"); INKFResponse vResponse = aContext.createResponseFrom(vSheetXML.toString()); vResponse.setExpiry(INKFResponse.EXPIRY_DEPENDENT); }
From source file:com.etest.view.tq.itemanalysis.FileUploadWindow.java
void readContentFromExcelFile(File excelFile) { try {/*from w ww. j a v a 2s.c om*/ POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(excelFile)); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(wb.getActiveSheetIndex()); HSSFRow row; HSSFCell cell; boolean stop = false; boolean nonBlankRowFound; int s; HSSFRow lastRow = null; while (stop == false) { nonBlankRowFound = false; lastRow = sheet.getRow(sheet.getLastRowNum()); for (s = lastRow.getFirstCellNum(); s <= lastRow.getLastCellNum(); s++) { cell = lastRow.getCell(s); if (cell != null && lastRow.getCell(s).getCellType() != HSSFCell.CELL_TYPE_BLANK) { nonBlankRowFound = true; } } if (nonBlankRowFound == true) { stop = true; } else { sheet.removeRow(lastRow); } } int rows; // No of rows rows = sheet.getPhysicalNumberOfRows(); int cols = 0; // No of columns int tmp = 0; // This trick ensures that we get the data properly even if it doesn't start from first few rows for (int i = 0; i < 10 || i < rows; i++) { row = sheet.getRow(i); if (row != null) { tmp = sheet.getRow(i).getPhysicalNumberOfCells(); if (tmp > cols) cols = tmp; } } List<ItemAnalysis> itemAnalysisList = new ArrayList<>(); List<Character> answer; ItemAnalysis itemAnalysis = null; for (int c = 0; c < cols; c++) { itemAnalysis = new ItemAnalysis(); answer = new ArrayList<>(); for (int r = 0; r < rows; r++) { row = sheet.getRow(r); if (row == null || row.toString().isEmpty()) { ShowErrorNotification.error("Remove all blank/empty rows after the last Item!"); return; } else { // if(row != null){ cell = row.getCell(c); if (cell == null || cell.toString().isEmpty()) { ShowErrorNotification.error("Remove all blank/empty columns after the last student!"); return; } else { // if(cell != null){ if (c != 0) { if (r == 0) { itemAnalysis.setStudentNumber(cell.toString().trim()); } else { answer.add(cell.toString().trim().charAt(0)); } } else { if (r != 0) { totalItems++; } } } } } if (c != 0) { itemAnalysis.setAnswer(answer); itemAnalysisList.add(itemAnalysis); } } if (tq.getCellItemIdByTQCoverageId(getTqCoverageId()).size() != totalItems) { ShowErrorNotification.error("Total Items do not MATCH!"); totalItems = 0; return; } studentNoAndTotalScore = new HashMap<>(); studentNoAndAnswer = new HashMap<>(); totalItems = 1; new Thread() { @Override public void run() { totalData = itemAnalysisList.size(); for (ItemAnalysis i : itemAnalysisList) { try { Thread.sleep(50); studentNoAndTotalScore.put(i.getStudentNumber(), ItemAnalysisInterpretation .getTotalScoresOfAllStudent(tqCoverageId, i.getAnswer())); studentNoAndAnswer.put(i.getStudentNumber(), i.getAnswer()); getUI().access(new Runnable() { @Override public void run() { if (totalItems < itemAnalysisList.size()) { analyze.setValue("Analyzing data.. " + CommonUtilities.roundOffToTwoDecimal((current / totalData) * 100) + "%"); current++; } else { analyze.setValue("Data analyzed... 100%"); getLowerAndUpperGroupStudent(studentNoAndTotalScore); HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); h.addComponent(viewTableProportion()); h.addComponent(viewStudentsTotalScore()); h.addComponent(approveItemAnalysis()); v.addComponent(h); v.addComponent(itemAnalysisGridPanel()); } } }); totalItems++; } catch (InterruptedException ex) { Logger.getLogger(FileUploadWindow.class.getName()).log(Level.SEVERE, null, ex); } } } }.start(); UI.getCurrent().setPollInterval(500); } catch (IOException ex) { Logger.getLogger(TQItemAnalysisUI.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.flexive.extractor.ExcelExtractor.java
License:Open Source License
private void processSheet(HSSFSheet sheet) { try {// ww w . jav a 2 s . com // Use the HFFS functions for the number of rows & columns int rowCount = sheet.getPhysicalNumberOfRows(); int colCount = sheet.getRow(0).getPhysicalNumberOfCells(); HSSFRow row; HSSFCell cell; String cellValue; for (int i = 0; i < rowCount; i++) { row = sheet.getRow(i); for (short j = 0; j < colCount; j++) { cell = row.getCell(j); if (cell != null) { try { switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_BOOLEAN: cellValue = String.valueOf(cell.getBooleanCellValue()); break; case HSSFCell.CELL_TYPE_NUMERIC: cellValue = String.valueOf(cell.getNumericCellValue()); break; case HSSFCell.CELL_TYPE_FORMULA: // Doesnt make much sense to index a cell formula cellValue = ""; break; case HSSFCell.CELL_TYPE_ERROR: cellValue = String.valueOf(cell.getErrorCellValue()); break; case HSSFCell.CELL_TYPE_BLANK: cellValue = ""; break; default: cellValue = cell.getStringCellValue(); } } catch (Exception exc) { cellValue = ""; } writer.write(FxSharedUtils.getBytes(cellValue)); } } } } catch (Exception eN) { System.out.println("Error reading sheet:" + eN.toString()); } }
From source file:com.frameworkset.platform.cms.searchmanager.extractors.CmsExtractorMsExcel.java
License:Open Source License
/** * Extracts the text from the Excel table content.<p> * /*from w ww. java2s .c om*/ * @param in the document input stream * @return the extracted text * @throws IOException if something goes wring */ protected String extractTableContent(InputStream in) throws IOException { HSSFWorkbook excelWb = new HSSFWorkbook(in); StringBuffer result = new StringBuffer(4096); int numberOfSheets = excelWb.getNumberOfSheets(); for (int i = 0; i < numberOfSheets; i++) { HSSFSheet sheet = excelWb.getSheetAt(i); int numberOfRows = sheet.getPhysicalNumberOfRows(); if (numberOfRows > 0) { if (CmsStringUtil.isNotEmpty(excelWb.getSheetName(i))) { // append sheet name to content if (i > 0) { result.append("\n\n"); } result.append(excelWb.getSheetName(i).trim()); result.append(":\n\n"); } Iterator rowIt = sheet.rowIterator(); while (rowIt.hasNext()) { HSSFRow row = (HSSFRow) rowIt.next(); if (row != null) { boolean hasContent = false; Iterator it = row.cellIterator(); while (it.hasNext()) { HSSFCell cell = (HSSFCell) it.next(); String text = null; try { switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_BLANK: case HSSFCell.CELL_TYPE_ERROR: // ignore all blank or error cells break; case HSSFCell.CELL_TYPE_NUMERIC: text = Double.toString(cell.getNumericCellValue()); break; case HSSFCell.CELL_TYPE_BOOLEAN: text = Boolean.toString(cell.getBooleanCellValue()); break; case HSSFCell.CELL_TYPE_STRING: default: text = cell.getStringCellValue(); break; } } catch (Exception e) { // ignore this cell } if (CmsStringUtil.isNotEmpty(text)) { result.append(text.trim()); result.append(' '); hasContent = true; } } if (hasContent) { // append a newline at the end of each row that has content result.append('\n'); } } } } } return result.toString(); }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.SequencingClasses.Classes.FilterTableModel.java
public void loadFilterTableModelfromSpreadsheet() { ArrayList<FilterSetup> load = new ArrayList(); HSSFSheet worksheet = HCAFLIMPluginFrame.wbLoad.getSheet("SpectralSequencing"); int RowSize = worksheet.getPhysicalNumberOfRows(); for (int RowNum = 0; RowNum < RowSize - 1; RowNum++) { HSSFRow row = worksheet.getRow(RowNum + 1); HSSFCell cell0 = row.getCell(0); HSSFCell cell1 = row.getCell(1); HSSFCell cell2 = row.getCell(2); HSSFCell cell3 = row.getCell(3); HSSFCell cell4 = row.getCell(4); HSSFCell cell5 = row.getCell(5); HSSFCell cell6 = row.getCell(6); HSSFCell cell7 = row.getCell(7); String delayss = cell7.getStringCellValue(); // some initializations for changing String of numbers to arrayList int strLength = delayss.length(); int count = 0; ArrayList<Integer> delays = new ArrayList(); String findStr = ","; int lastIndex = 0; String label = null;//from w w w.j a v a2 s . c o m int labelInt = 0; int bbb = 0; // counting entries in txt file for property while (lastIndex != -1) { lastIndex = delayss.indexOf(findStr, lastIndex); if (lastIndex != -1) { count++; lastIndex += findStr.length(); } } String subStr1 = delayss.substring(1, strLength - 1); // writes every single value into arrayList for (int i = 0; i < count; i++) { bbb = subStr1.indexOf(","); label = subStr1.substring(0, bbb); labelInt = Integer.parseInt(label); delays.add(labelInt); subStr1 = subStr1.substring(bbb + 2); } // writes last entry label = subStr1; labelInt = Integer.parseInt(label); delays.add(labelInt); // FilterSetup fov = new FilterSetup( cell0.getStringCellValue(), cell1.getStringCellValue(), cell2.getStringCellValue(), cell3.getStringCellValue(), cell4.getStringCellValue(), cell5.getStringCellValue(), (int) cell6.getNumericCellValue(), delays); // load.add(fov); } data_ = load; fireTableDataChanged(); }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.SequencingClasses.Classes.FOVTableModel.java
public void loadFOVTableModelfromSpreadsheet() { ArrayList<FOV> load = new ArrayList(); HSSFSheet worksheet = HCAFLIMPluginFrame.wbLoad.getSheet("XYSequencing"); int RowSize = worksheet.getPhysicalNumberOfRows(); for (int RowNum = 0; RowNum < RowSize - 1; RowNum++) { HSSFRow row = worksheet.getRow(RowNum + 1); HSSFCell cell0 = row.getCell(0); HSSFCell cell1 = row.getCell(1); HSSFCell cell2 = row.getCell(2); HSSFCell cell3 = row.getCell(3); HSSFCell cell4 = row.getCell(4); FOV fov = new FOV(cell1.getNumericCellValue(), cell2.getNumericCellValue(), cell3.getNumericCellValue(), cell0.getStringCellValue(), pp_); fov.setGroup(cell4.getStringCellValue()); load.add(fov);/*w w w. j a va 2 s . c om*/ } data_ = load; fireTableDataChanged(); }
From source file:com.glaf.base.modules.todo.TodoXlsReader.java
License:Apache License
public List<Todo> readXls(java.io.InputStream inputStream) { List<Todo> todos = new java.util.ArrayList<Todo>(); HSSFWorkbook wb = null;//from ww w . j a va 2s . c o m try { wb = new HSSFWorkbook(inputStream); } catch (Exception ex) { throw new RuntimeException(ex); } HSSFSheet sheet = wb.getSheetAt(0); HSSFRow row = sheet.getRow(1); Map<Integer, String> keyMap = new java.util.HashMap<Integer, String>(); Map<String, Object> dataMap = new java.util.HashMap<String, Object>(); int cells = row.getPhysicalNumberOfCells(); for (int colIndex = 0; colIndex < cells; colIndex++) { HSSFCell cell = row.getCell(colIndex); keyMap.put(colIndex, cell.getStringCellValue()); } Set<String> keys = new HashSet<String>(); for (int rowIndex = 2; rowIndex < sheet.getPhysicalNumberOfRows(); rowIndex++) { HSSFRow rowx = sheet.getRow(rowIndex); if (rowx == null) { continue; } // System.out.println(); dataMap.clear(); for (int colIndex = 0; colIndex < cells; colIndex++) { String fieldName = keyMap.get(colIndex); HSSFCell cell = rowx.getCell(colIndex); if (cell == null) { continue; } Object cellValue = null; switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_FORMULA: break; case HSSFCell.CELL_TYPE_BOOLEAN: cellValue = cell.getBooleanCellValue(); break; case HSSFCell.CELL_TYPE_NUMERIC: cellValue = cell.getNumericCellValue(); break; case HSSFCell.CELL_TYPE_STRING: if (StringUtils.isNotEmpty(cell.getRichStringCellValue().getString())) { cellValue = cell.getRichStringCellValue().getString(); } break; default: if (StringUtils.isNotEmpty(cell.getStringCellValue())) { cellValue = cell.getStringCellValue(); } break; } if (cellValue != null) { dataMap.put(fieldName, cellValue); if ("id".equals(fieldName)) { cellValue = cellValue.toString().substring(0, cellValue.toString().indexOf(".")); dataMap.put(fieldName, cellValue); } } } if (dataMap.get("code") != null) { String id = ParamUtils.getString(dataMap, "id"); if (!keys.contains(ParamUtils.getString(dataMap, "code"))) { if (id != null && StringUtils.isNotEmpty(id)) { Todo model = new Todo(); Tools.populate(model, dataMap); if (ParamUtils.getInt(dataMap, "limitDay") > 0) { model.setLimitDay(ParamUtils.getInt(dataMap, "limitDay")); } todos.add(model); keys.add(model.getCode()); } } } } return todos; }