break; case FORMULA: setCellFormula(srcCell.getCellFormula()); break; case BLANK:
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet(); XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook); XSSFCell cellvalue = sheet.createRow(0).createCell(0); sheet.getRow(0).createCell(1).setCellValue(2); sheet.getRow(0).createCell(2).setCellValue(5); cellvalue.setCellFormula("B1+C1"); if (cellvalue.getCellType() == XSSFCell.CELL_TYPE_FORMULA) { evaluator.evaluateFormulaCell(cellvalue); } System.out.println(cellvalue.getNumericCellValue());
private static void appendMentoringTotalRow(XSSFWorkbook wb, XSSFSheet sheet, int rowNum, int start, int end) { Font boldFont = wb.createFont(); boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD); boldFont.setColor((short) 0x0); XSSFCellStyle commentCell = wb.createCellStyle(); commentCell.setBorderTop(CellStyle.BORDER_THIN); XSSFCellStyle totalCell = wb.createCellStyle(); totalCell.setBorderTop(CellStyle.BORDER_THIN); totalCell.setFont(boldFont); XSSFCellStyle totalCellRight = wb.createCellStyle(); totalCellRight.setBorderTop(CellStyle.BORDER_THIN); totalCellRight.setAlignment(HorizontalAlignment.RIGHT); totalCellRight.setFont(boldFont); XSSFRow row = sheet.createRow(rowNum); XSSFCell t1 = row.createCell(0); t1.setCellValue("Total:"); t1.setCellStyle(totalCellRight); XSSFCell t2 = row.createCell(1); t2.setCellFormula("SUM(B" + start + ":B" + end + ")"); t2.setCellStyle(totalCell); XSSFCell t3 = row.createCell(2); t3.setCellStyle(totalCell); XSSFCell t4 = row.createCell(3); t4.setCellStyle(commentCell); }
private static void appendTotalRow(XSSFWorkbook wb, XSSFSheet sheet, int rowNum) { Font boldFont = wb.createFont(); boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD); boldFont.setColor((short) 0x0); XSSFCellStyle commentCell = wb.createCellStyle(); commentCell.setBorderTop(CellStyle.BORDER_THIN); XSSFCellStyle totalCell = wb.createCellStyle(); totalCell.setBorderTop(CellStyle.BORDER_THIN); totalCell.setFont(boldFont); XSSFCellStyle totalCellRight = wb.createCellStyle(); totalCellRight.setBorderTop(CellStyle.BORDER_THIN); totalCellRight.setAlignment(HorizontalAlignment.RIGHT); totalCellRight.setFont(boldFont); XSSFRow row = sheet.createRow(rowNum); XSSFCell t1 = row.createCell(0); t1.setCellValue("Total:"); t1.setCellStyle(totalCellRight); XSSFCell t2 = row.createCell(1); t2.setCellFormula("SUM(B1:B" + rowNum + ")*" + TEST_PADDING); t2.setCellStyle(totalCell); XSSFCell t3 = row.createCell(2); t3.setCellStyle(totalCell); XSSFCell t4 = row.createCell(3); t4.setCellValue("Total with Testing & App Migration Factors"); t4.setCellStyle(commentCell); }
String cellFormula = tplSheetCell.getCellFormula(); if (cellFormula != null) sheetCell.setCellFormula(cellFormula); break; case Cell.CELL_TYPE_BLANK:
break; case FORMULA: setCellFormula(srcCell.getCellFormula()); break; case BLANK: