Example usage for org.apache.poi.ss.usermodel Cell getNumericCellValue

List of usage examples for org.apache.poi.ss.usermodel Cell getNumericCellValue

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Cell getNumericCellValue.

Prototype

double getNumericCellValue();

Source Link

Document

Get the value of the cell as a number.

Usage

From source file:com.photon.phresco.framework.commons.FrameworkUtil.java

License:Apache License

private static String getValue(Cell cell) {
    if (cell != null) {
        if (Cell.CELL_TYPE_STRING == cell.getCellType()) {
            return cell.getStringCellValue();
        }// w ww .  ja  va 2  s  . c  o  m

        if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) {
            return String.valueOf(cell.getNumericCellValue());
        }
    }

    return null;
}

From source file:com.photon.phresco.service.tools.AdminConfigGenerator.java

License:Apache License

private String getValue(Cell cell) {
    if (Cell.CELL_TYPE_STRING == cell.getCellType()) {
        System.out.println("hello-->" + cell.getStringCellValue());
        return cell.getStringCellValue();
    }//from w  w w.j a  v a2  s . c  om

    if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) {
        System.out.println("hello2");
        return String.valueOf(cell.getNumericCellValue());
    }
    return null;
}

From source file:com.photon.phresco.service.tools.ConfigDataGenerator.java

License:Apache License

private static String getValue(Cell cell) {
    if (Cell.CELL_TYPE_STRING == cell.getCellType()) {
        return cell.getStringCellValue();
    }/*w ww  . ja  va2s .c om*/

    if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) {
        return String.valueOf(cell.getNumericCellValue());
    }

    return null;
}

From source file:com.photon.phresco.service.tools.JsLibraryGenerator.java

License:Apache License

private String getValue(Cell cell) {
    if (Cell.CELL_TYPE_STRING == cell.getCellType()) {
        return cell.getStringCellValue();
    }//from  w  w w .ja v  a  2  s  .  c om

    if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) {
        return String.valueOf(cell.getNumericCellValue());
    }

    return null;
}

From source file:com.photon.phresco.service.tools.PilotProjectGenerator.java

License:Apache License

private String getValue(Cell cell) {
    if (Cell.CELL_TYPE_STRING == cell.getCellType()) {
        return cell.getStringCellValue();
    }//from   w  w w  .  java2 s  .co m
    if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) {
        return String.valueOf(cell.getNumericCellValue());
    }
    return null;
}

From source file:com.photon.phresco.service.tools.PilotProjectGenerator.java

License:Apache License

private void createJSLibrary(String tech, Row row) {
    Cell srno = row.getCell(0);
    Double no = null;/*from w ww. j  a v  a2  s .c om*/
    if (srno != null && Cell.CELL_TYPE_BLANK != srno.getCellType()) {
        no = srno.getNumericCellValue();
    }
    Cell names = row.getCell(1);
    String name = null;
    if (names != null && Cell.CELL_TYPE_BLANK != names.getCellType()) {
        name = getValue(names);
    }
    Cell versions = row.getCell(2);
    String version = getValue(versions);
    String identifier = ID1 + name + STR_UNDER_SCORE + version;
    JSSNO_AND_NAME_MAP.put(no, identifier);
    JSSNO_AND_NAME.put(no, name);
    JSSNO_AND_VERSION.put(no, version);
}

From source file:com.photon.phresco.service.tools.PilotProjectGenerator.java

License:Apache License

private void createModule(String tech, Row row) {
    Cell srno = row.getCell(0);
    Double no = null;// w  ww  . ja va2s .  c om
    if (srno != null && Cell.CELL_TYPE_BLANK != srno.getCellType()) {
        no = srno.getNumericCellValue();
    }
    Cell names = row.getCell(1);
    String name = null;
    if (names != null && Cell.CELL_TYPE_BLANK != names.getCellType()) {
        name = getValue(names);
    }
    Cell versions = row.getCell(2);
    String version = null;
    if (versions != null && Cell.CELL_TYPE_BLANK != versions.getCellType()) {
        version = getValue(versions);
    }
    String identifier = ID + name + STR_UNDER_SCORE + version;
    SNO_AND_NAME_MAP.put(no, identifier);
    SNO_AND_NAME.put(no, name);
    SNO_AND_VERSION.put(no, version);
}

From source file:com.photon.phresco.service.tools.TechnologyDataGenerator.java

License:Apache License

/**
 * Handle dependencies./*  ww  w. ja va2  s . c  o m*/
 *
 * @param modules
 *            the modules
 * @return the modules
 */
//   private Modules handleDependencies(Modules modules) {
//      Modules modifiedModules = new Modules();
//      List<Module> moduleList = modules.getModule();
//      for (Module module : moduleList) {
//         List<String> depModNameList = new ArrayList<String>();
//         String modName = module.getId();
//         String[] depList = NAME_AND_DEP_MAP.get(modName);
//         if (depList == null) {
//            modifiedModules.getModule().add(module);
//            continue;
//         }
//         for (String dep : depList) {
//            int depNo = (int) (Double.valueOf(dep).doubleValue());
//            String depModName = SNO_AND_NAME_MAP.get(String.valueOf(depNo));
//            depModNameList.add(depModName);
//         }
//
//         if (!depModNameList.isEmpty()) {
//            module.getDependentModules().addAll(depModNameList);
//         }
//
//         modifiedModules.getModule().add(module);
//      }
//      return modifiedModules;
//   }

private ModuleGroup createModuleGroup(String techId, Row row) throws PhrescoException {
    if (S_LOGGER.isDebugEnabled()) {
        S_LOGGER.debug("row " + row.getRowNum());
    }
    ModuleGroup moduleGroup = new ModuleGroup();

    Cell serialNo = row.getCell(0);
    if (serialNo == null || Cell.CELL_TYPE_BLANK == serialNo.getCellType()) {
        return null;
    }

    String name = row.getCell(1).getStringCellValue();

    String identifier = ID + row.getCell(1).getStringCellValue().toLowerCase()
            .replace(ServerConstants.STR_BLANK_SPACE, ServerConstants.STR_UNDER_SCORE);
    String no = String.valueOf(identifier);

    String version = "1.0";
    Cell versionCell = row.getCell(2);
    String[] versionArray = null;
    if (versionCell != null && Cell.CELL_TYPE_BLANK != versionCell.getCellType()) {
        String versions = getValue(versionCell);
        versionArray = StringUtils.split(versions, DELIMITER);
        NAME_AND_DEP_MAP.put(identifier, versionArray);
    }

    Cell requireCell = row.getCell(3);
    String[] reqArray = null;
    if (requireCell != null && Cell.CELL_TYPE_BLANK != requireCell.getCellType()) {
        String reqs = getValue(requireCell);
        reqArray = StringUtils.split(reqs, DELIMITER);
    }

    Cell coreCell = row.getCell(4);
    String[] coreArray = null;
    if (coreCell != null && Cell.CELL_TYPE_BLANK != coreCell.getCellType()) {
        String core = getValue(coreCell);
        coreArray = StringUtils.split(core, DELIMITER);
    }

    int sNoInt = (int) serialNo.getNumericCellValue();
    SNO_AND_NAME_MAP.put(String.valueOf(sNoInt), identifier);

    Cell depCell = row.getCell(5);
    if (depCell != null && Cell.CELL_TYPE_BLANK != depCell.getCellType()) {
        String depModules = getValue(depCell);
        String[] depModuleIds = StringUtils.split(depModules, DELIMITER);
        NAME_AND_DEP_MAP.put(identifier, depModuleIds);
    }

    List<Documentation> docs = new ArrayList<Documentation>();
    Cell helptext = row.getCell(9);
    if (helptext != null && Cell.CELL_TYPE_BLANK != helptext.getCellType()) {
        Documentation doc = new Documentation();
        String docContent = helptext.getStringCellValue();
        doc.setContent(docContent);
        doc.setType(DocumentationType.HELP_TEXT);
        docs.add(doc);
    }

    Cell description = row.getCell(12);
    if (description != null && Cell.CELL_TYPE_BLANK != description.getCellType()) {
        Documentation doc = new Documentation();
        String docContent = description.getStringCellValue();
        doc.setContent(docContent);
        doc.setType(DocumentationType.DESCRIPTION);
        docs.add(doc);

    }
    moduleGroup.setDocs(docs);

    String fileExt = "zip";
    Cell filenameCell = row.getCell(13);
    if (filenameCell != null && Cell.CELL_TYPE_BLANK != filenameCell.getCellType()) {
        if (S_LOGGER.isDebugEnabled()) {
            S_LOGGER.debug("no " + no);
            S_LOGGER.debug("filename.getCellType() " + filenameCell.getCellType());
        }

        String filePath = filenameCell.getStringCellValue().trim();

        if (filePath.endsWith(".tar.gz")) {
            fileExt = "tar.gz";
        } else if (filePath.endsWith(".tar")) {
            fileExt = "tar";
        } else if (filePath.endsWith(".zip")) {
            fileExt = "zip";
        } else if (filePath.endsWith(".jar")) {
            fileExt = "jar";
        }

        //      publishModule(tech, module, filePath, fileExt);
    }

    List<Module> modulesList = createModuleList(versionArray, reqArray, coreArray, techId, fileExt, identifier);

    Cell imagenameCell = row.getCell(16);
    if (imagenameCell != null && Cell.CELL_TYPE_BLANK != imagenameCell.getCellType()) {

        String imagePath = imagenameCell.getStringCellValue().trim();
        //        String imageUrl = createImageContentUrl("");
        //         module.setImageURL(imageUrl);
        moduleGroup.setImageURL(imagePath);
    }

    Cell groupNameCell = row.getCell(14);
    if (groupNameCell != null && Cell.CELL_TYPE_BLANK != groupNameCell.getCellType()) {
        if (S_LOGGER.isDebugEnabled()) {
            S_LOGGER.debug("no " + no);
            S_LOGGER.debug("groupname.getCellType() " + groupNameCell.getCellType());
        }
        String groupId = groupNameCell.getStringCellValue();
        moduleGroup.setGroupId(groupId);
    }

    Cell artifactCell = row.getCell(15);
    if (artifactCell != null && Cell.CELL_TYPE_BLANK != artifactCell.getCellType()) {
        if (S_LOGGER.isDebugEnabled()) {
            S_LOGGER.debug("no " + no);
            S_LOGGER.debug("artifact name.getCellType() " + artifactCell.getCellType());
        }
        String artifactId = artifactCell.getStringCellValue();
        moduleGroup.setArtifactId(artifactId);
    }
    moduleGroup.setName(name);
    moduleGroup.setTechId(techId);
    moduleGroup.setVersions(modulesList);
    moduleGroup.setSystem(true);
    moduleGroup.setModuleId(identifier);
    moduleGroup.setType("module");
    moduleGroup.setCustomerId("photon");
    return moduleGroup;
}

From source file:com.photon.phresco.service.tools.VideoInfoGenerator.java

License:Apache License

 private static String getValue(Cell cell) {
   if (Cell.CELL_TYPE_STRING == cell.getCellType()) {
      return cell.getStringCellValue();
   }//from   w  ww .  j a  v  a  2 s  . c om

   if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) {
      return String.valueOf(cell.getNumericCellValue());
   }

   return null;
}

From source file:com.plugin.excel.util.ExcelUtil.java

License:Apache License

/**
 * @param oldCell//from ww w .  jav a 2 s .  com
 * @param newCell
 * @param styleMap
 */
public static void copyCell(Cell oldCell, Cell newCell, Map<Integer, CellStyle> styleMap) {
    if (styleMap != null) {
        if (oldCell.getSheet().getWorkbook() == newCell.getSheet().getWorkbook()) {
            newCell.setCellStyle(oldCell.getCellStyle());
        } else {
            int stHashCode = oldCell.getCellStyle().hashCode();
            CellStyle newCellStyle = styleMap.get(stHashCode);
            if (newCellStyle == null) {
                newCellStyle = newCell.getSheet().getWorkbook().createCellStyle();
                newCellStyle.cloneStyleFrom(oldCell.getCellStyle());
                styleMap.put(stHashCode, newCellStyle);
            }
            newCell.setCellStyle(newCellStyle);
        }
    }
    switch (oldCell.getCellType()) {
    case Cell.CELL_TYPE_STRING:
        newCell.setCellValue(oldCell.getStringCellValue());
        break;
    case Cell.CELL_TYPE_NUMERIC:
        newCell.setCellValue(oldCell.getNumericCellValue());
        break;
    case Cell.CELL_TYPE_BLANK:
        newCell.setCellType(Cell.CELL_TYPE_BLANK);
        break;
    case Cell.CELL_TYPE_BOOLEAN:
        newCell.setCellValue(oldCell.getBooleanCellValue());
        break;
    case Cell.CELL_TYPE_ERROR:
        newCell.setCellErrorValue(oldCell.getErrorCellValue());
        break;
    case Cell.CELL_TYPE_FORMULA:
        newCell.setCellFormula(oldCell.getCellFormula());
        break;
    default:
        break;
    }

}