Usages of

org.apache.poi.xssf.streaming.SXSSFCell.getAddress()
public void setFormula(int introw, List result, SXSSFWorkbook newworkbook, SXSSFRow row, int itera, Modul modul, String aggregate) { // offset de d��calage lorsque un moule a ��t�� trait�� int offsetCol = OffsetColumn; // num��ro de colonne �� traiter. int nocol = 0; for (Wycccell event : (List<Wycccell>) result) { if (event.getCellcolumn() >= StartColumnformule && event.getCellcolumn() <= EndColumnFormule) { Float Amount; try { if (modul != null) { Amount = modul.getModulprice();// Float.parseFloat(modul.getModulprice()); } else { Amount = 0f; } } catch (NumberFormatException e) { // TODO Auto-generated catch block // e.printStackTrace(); Amount = 0f; } nocol = event.getCellcolumn() + (OffsetColumn * (itera - 1)); SXSSFCell cell = row.createCell(nocol); if (nocol == EndColumnFormule + (OffsetColumn * (itera - 1))) { String formuleagg = ""; // modul.getForfaitpercentage(); // on recup��re le pourcentage et la valeur de l'aggregate if (modul.getForfaitpercentage() == 1) { formuleagg = cell.getAddress().toString(); } else { formuleagg = "(if(" + cell.getAddress().toString() + ">(" + aggregate + "/12)," + aggregate + "/12," + cell.getAddress().toString() + ")*" + Amount.toString() + ")"; } logger.info("Iteration : " + itera + " - Num col : " + nocol + " - Total : " + xldformuleaggaregate + " - ajout : " + formuleagg); xldformuleaggaregate = xldformuleaggaregate + formuleagg + "+"; } CellStyle style1 = newworkbook.createCellStyle(); style1.setBorderBottom((short) event.getBorderbottom()); style1.setBorderTop((short) event.getBordertop()); style1.setBorderLeft((short) event.getBorterleft()); style1.setBorderRight((short) event.getBorderright()); style1.setDataFormat((short) event.getDataformat()); // style1.setDataFormatString ( event.getDataformatstring()); style1.setBottomBorderColor((short) event.getBordercolorbottom()); style1.setBottomBorderColor((short) event.getBordercolortop()); style1.setRightBorderColor((short) event.getBordercolorright()); style1.setLeftBorderColor((short) event.getBordercolorleft()); style1.setAlignment((short) event.getHalignement()); style1.setVerticalAlignment((short) event.getValignement()); style1.setFillBackgroundColor(HSSFColor.YELLOW.index);// (short) // event.getBaxkgroundcolor()); // style1.setFillForegroundColor ((short) // event.getFrontgroundcolor()); style1.setFillPattern(CellStyle.NO_FILL);// (short) // event.getPattern()); // style1.setIndention((short) event.getIndention()); if ((event.getFormulecell() != null)) { String laformule = event.getFormulecell(); // logger.info("Formule �� parser : " + laformule); laformule = getFormuleRegex(laformule, "([$A-Z]+)([$0-9]+)", "([$0-9]+)"); // logger.info("Formule pars��e : " + laformule); // laformule = laformule.replace("5", "%d"); // laformule = laformule.replace("14", "%d"); int therow = introw;// + 1; laformule = String.format(laformule, therow, therow, therow, therow, therow, therow, therow, therow, therow); Tools newformule = new Tools(); String lanewformule = Tools.getNewNumColonne(laformule, "[$A-Z]*", 26, OffsetColumn * (itera - 1)); cell.setCellFormula(lanewformule); } String lavaleur = null; if ((event.getValeurcell() != null)) { if (nocol == (StartColumnformule + (OffsetColumn * (itera - 1)))) { lavaleur = modul.getModulcategory(); } else if (nocol == (StartColumnformule + 1 + (OffsetColumn * (itera - 1)))) { lavaleur = modul.getModulfournisseur(); } else if (nocol == (StartColumnformule + 2 + (OffsetColumn * (itera - 1)))) { lavaleur = modul.getModullabel(); } else if (nocol == (StartColumnformule + 6 + (OffsetColumn * (itera - 1)))) { if (modul.getCalculmode().equals("MONTHLY")) { lavaleur = event.getValeurcell(); } else if (modul.getCalculmode().equals("DAILY")) { lavaleur = modul.getModulprice().toString();// valuecell; float myfloat = Float.parseFloat(lavaleur); cell.setCellValue(myfloat); } } else if (nocol == (StartColumnformule + 7 + (OffsetColumn * (itera - 1)))) { if (modul.getCalculmode().equals("MONTHLY")) { lavaleur = event.getValeurcell(); } else if (modul.getCalculmode().equals("DAILY")) { float myfloat = modul.getForfaitpercentage() / 100; lavaleur = String.valueOf(myfloat);// valuecell; myfloat = Float.parseFloat(lavaleur); cell.setCellValue(myfloat); } } else if (nocol == (StartColumnformule + 8 + (OffsetColumn * (itera - 1)))) { if (modul.getCalculmode().equals("MONTHLY")) { lavaleur = event.getValeurcell(); } else if (modul.getCalculmode().equals("DAILY")) { lavaleur = event.getValeurcell(); } } else if (nocol == (StartColumnformule + 9 + (OffsetColumn * (itera - 1)))) { if (modul.getCalculmode().equals("MONTHLY")) { lavaleur = modul.getModulprice().toString();// valuecell; float myfloat = Float.parseFloat(lavaleur); cell.setCellValue(myfloat); } else if (modul.getCalculmode().equals("DAILY")) { lavaleur = modul.getModulprice().toString();// valuecell; float myfloat = Float.parseFloat(lavaleur); cell.setCellValue(myfloat); } } else { lavaleur = event.getValeurcell(); } if (event.getTypecell() == Cell.CELL_TYPE_NUMERIC) { float myfloat = 0; try { myfloat = Float.parseFloat(lavaleur); } catch (Exception e) { // TODO Auto-generated catch block logger.info("valeur pars�� en float " + lavaleur); logger.info("valeur colonne " + event.getCellcolumn()); logger.info(e); e.printStackTrace(); } cell.setCellValue(myfloat); } else if (event.getTypecell() == Cell.CELL_TYPE_STRING) { cell.setCellValue(lavaleur); } cell.setCellStyle(style1); } } // fin du if } }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes