Example usage for org.apache.poi.hssf.usermodel HSSFDataFormat getBuiltinFormat

List of usage examples for org.apache.poi.hssf.usermodel HSSFDataFormat getBuiltinFormat

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFDataFormat getBuiltinFormat.

Prototype

public static String getBuiltinFormat(short index) 

Source Link

Document

get the format string that matches the given format index

Usage

From source file:jp.co.opentone.bsol.framework.core.generator.excel.strategy.PoiWorkbookGeneratorStrategy.java

License:Apache License

private HSSFCellStyle initializeDateCellStyle(HSSFWorkbook workbook, HSSFCellStyle baseStyle) {
    HSSFCellStyle dateStyle = workbook.createCellStyle();
    dateStyle.cloneStyleFrom(baseStyle);
    dateStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("d-mmm-yy"));
    return dateStyle;
}

From source file:lu.tudor.santec.dicom.gui.header.selector.ExportToXSL.java

License:Open Source License

@SuppressWarnings("deprecation")
public void println(Object[] line) {
    //       Create a row and put some cells in it. Rows are 0 based.
    HSSFRow row = sheet.createRow((short) rowIndex);

    boolean printed = true;
    for (int i = 0; i < line.length; i++) {
        try {/*from w ww.  ja  va 2 s . co m*/
            Date interValue;
            interValue = (Date) line[i];
            System.out.println(interValue + " " + line[i]);
            cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
            row.createCell((short) i).setCellValue(interValue);
            row.getCell((short) i).setCellStyle(cellStyle);
            printed = true;
        } catch (Exception e) {
            //             e.printStackTrace();
            printed = false;
        }
        try {
            if (!printed) {
                double interValue;
                interValue = Double.parseDouble(line[i].toString());
                row.createCell((short) i).setCellValue(interValue);
                printed = true;
            }
        } catch (Exception e) {
            //             e.printStackTrace();
            printed = false;
        }
        if (!printed) {
            try {
                String interValue = line[i].toString();
                row.createCell((short) i).setCellValue(interValue);
                printed = true;
            } catch (Exception e) {
                row.createCell((short) i).setCellValue("");
            }
        }
    }

    rowIndex++;
}

From source file:nc.noumea.mairie.appock.services.impl.ExportExcelServiceImpl.java

License:Open Source License

private void construitEnteteNumeroMarcheEtSoldeCommande(Workbook wb, Map<Service, List<ArticleDemande>> map,
        AbstractEntity abstractEntity, Service service, Sheet sheet) {
    Row row = createRowGeneric(sheet, LIGNE_NUMERO_MARCHE_ET_SOLDE_COMMANDE, 500);
    Cell cell = row.createCell(0);/*from   w  ww .j  av  a 2 s.c o  m*/
    if (abstractEntity instanceof SousMarche) {
        cell.setCellValue("March Nouma n: " + ((SousMarche) abstractEntity).getNumero());
        cell.setCellStyle(createCellWithBorderAndColor(wb, BorderStyle.THIN, IndexedColors.TAN, false));
    }

    // Cell Montant de la commande
    cell = row.createCell(6);

    int prixTotalService = 0;
    for (ArticleDemande articleDemande : map.get(service)) {
        prixTotalService += articleDemande.getTotalPrixCommande();
    }
    cell.setCellValue(prixTotalService);
    CellStyle style = createCellWithBorderAndColor(wb, BorderStyle.THIN, null, false);
    style.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));
    cell.setCellStyle(style);
}

From source file:nc.noumea.mairie.appock.services.impl.ExportExcelServiceImpl.java

License:Open Source License

private void remplitLigneArticle(Workbook wb, List<ArticleDemande> listeArticleDemande, Sheet sheet) {
    int numRow = 10;
    Map<ArticleCatalogue, Integer> mapArticleQuantite = new HashMap<>();

    for (ArticleDemande articleDemande : listeArticleDemande) {
        ArticleCatalogue articleCatalogue = articleDemande.getArticleCatalogue();
        Integer quantite = mapArticleQuantite.get(articleCatalogue);
        if (quantite != null) {
            mapArticleQuantite.replace(articleCatalogue, quantite + articleDemande.getQuantiteCommande());
        } else {//  w ww. ja v a2s  .c o m
            mapArticleQuantite.put(articleCatalogue, articleDemande.getQuantiteCommande());
        }
    }

    List<ArticleCatalogue> listeArticleCatalogue = new ArrayList(mapArticleQuantite.keySet());
    Collections.sort(listeArticleCatalogue, new ArticleCatalogueComparator());

    for (ArticleCatalogue articleCatalogue : listeArticleCatalogue) {
        Row row = createRowGeneric(sheet, numRow, 500);
        row.createCell(0).setCellValue(articleCatalogue.getReference());
        row.createCell(1).setCellValue(articleCatalogue.getLibelle());
        row.createCell(2).setCellValue(articleCatalogue.getPrix());
        row.createCell(3).setCellValue(articleCatalogue.getLibelleColisage());
        row.createCell(4).setCellValue(mapArticleQuantite.get(articleCatalogue));

        String strFormula = "C" + (numRow + 1) + "*E" + (numRow + 1) + "";
        Cell cell = row.createCell(5);
        cell.setCellType(CellType.FORMULA);
        cell.setCellFormula(strFormula);

        CellStyle style = createCellWithBorderAndColor(wb, BorderStyle.THIN, IndexedColors.LIGHT_YELLOW, false);
        CellStyle stylePrix = createCellWithBorderAndColor(wb, BorderStyle.THIN, IndexedColors.LIGHT_YELLOW,
                false);
        stylePrix.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));

        row.getCell(0).setCellStyle(style);
        row.getCell(1).setCellStyle(style);
        row.getCell(2).setCellStyle(stylePrix);
        row.getCell(3).setCellStyle(style);
        row.getCell(4).setCellStyle(style);
        row.getCell(5).setCellStyle(stylePrix);
        numRow++;
    }
}

From source file:net.chaosserver.timelord.data.ExcelDataReaderWriter.java

License:Open Source License

/**
 * Builds a map of style name to HSSFCellStyle objects that can be used to
 * mark cells with similar styles.// www .  ja  v  a2s .  c  o m
 *
 * @param wb the workbook needed to create the objects
 * @return the map of styles
 */
protected Map<String, HSSFCellStyle> buildStyleMap(HSSFWorkbook wb) {
    Map<String, HSSFCellStyle> styleMap = new HashMap<String, HSSFCellStyle>();

    HSSFCellStyle style;
    HSSFFont font;

    style = wb.createCellStyle();
    font = wb.createFont();
    // font.setItalic(true);
    font.setColor((short) 0xc); // blue
    style.setFont(font);
    styleMap.put("taskNoteStyle", style);

    style = wb.createCellStyle();
    font = wb.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    style.setFont(font);
    style.setBorderLeft(HSSFCellStyle.BORDER_DOUBLE);
    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleMap.put("taskNameHeaderStyle", style);

    style = wb.createCellStyle();
    style.setBorderLeft(HSSFCellStyle.BORDER_DOUBLE);
    styleMap.put("taskNameStyle", style);

    style = wb.createCellStyle();
    style.setBorderTop(HSSFCellStyle.BORDER_DOUBLE);
    style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    styleMap.put("topRowStyle", style);

    style = wb.createCellStyle();
    style.setBorderTop(HSSFCellStyle.BORDER_DOUBLE);
    style.setBorderLeft(HSSFCellStyle.BORDER_DOUBLE);
    styleMap.put("topLeftStyle", style);

    style = wb.createCellStyle();
    style.setBorderTop(HSSFCellStyle.BORDER_DOUBLE);
    style.setBorderRight(HSSFCellStyle.BORDER_DOUBLE);
    styleMap.put("topRightStyle", style);

    style = wb.createCellStyle();
    font = wb.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    style.setFont(font);
    style.setBorderRight(HSSFCellStyle.BORDER_DOUBLE);
    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    styleMap.put("totalHeaderStyle", style);

    style = wb.createCellStyle();
    style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    style.setBorderRight(HSSFCellStyle.BORDER_DOUBLE);
    styleMap.put("totalColumnStyle", style);

    style = wb.createCellStyle();
    style.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    style.setFont(font);
    styleMap.put("boldDateStyle", style);

    style = wb.createCellStyle();
    style.setBorderTop(HSSFCellStyle.BORDER_THIN);
    style.setBorderBottom(HSSFCellStyle.BORDER_DOUBLE);
    style.setBorderLeft(HSSFCellStyle.BORDER_DOUBLE);
    styleMap.put("bottomLeftStyle", style);

    style = wb.createCellStyle();
    style.setBorderTop(HSSFCellStyle.BORDER_THIN);
    style.setBorderBottom(HSSFCellStyle.BORDER_DOUBLE);
    style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    style.setBorderRight(HSSFCellStyle.BORDER_DOUBLE);
    styleMap.put("bottomRightStyle", style);

    style = wb.createCellStyle();
    style.setBorderTop(HSSFCellStyle.BORDER_THIN);
    style.setBorderBottom(HSSFCellStyle.BORDER_DOUBLE);
    styleMap.put("bottomStyle", style);

    return styleMap;
}

From source file:net.chaosserver.timelord.data.ExcelUglyDataReaderWriter.java

License:Open Source License

/**
 * Generates the workbook that contains all of the data for the excel
 * document./*  w  w w.  j av a  2s.  co m*/
 *
 * @param timelordData the data object to generate the workbook for
 * @return the workbook of data
 */
protected HSSFWorkbook generateWorkbook(TimelordData timelordData) {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    sheet.setColumnWidth((short) 1, (short) 10000);

    HSSFCellStyle dateStyle = wb.createCellStyle();
    dateStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));

    List<TimelordTask> taskCollection = timelordData.getTaskCollection();
    Iterator<TimelordTask> taskIterator = taskCollection.iterator();
    // Calendar weekStart = Calendar.getInstance();

    // Make the headers
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell((short) 0);
    cell.setCellValue("Date");
    cell = row.createCell((short) 1);
    cell.setCellValue("Task Name");
    cell = row.createCell((short) 2);
    cell.setCellValue("Hours");
    cell = row.createCell((short) 3);
    cell.setCellValue("Note");

    int rowNum = 1;
    while (taskIterator.hasNext()) {
        TimelordTask timelordTask = (TimelordTask) taskIterator.next();
        if (timelordTask.isExportable()) {
            String taskName = timelordTask.getTaskName();
            List<TimelordTaskDay> taskDayList = timelordTask.getTaskDayList();

            Iterator<TimelordTaskDay> taskDayIterator = taskDayList.iterator();

            while (taskDayIterator.hasNext()) {
                TimelordTaskDay timelordTaskDay = (TimelordTaskDay) taskDayIterator.next();

                if (timelordTaskDay.getHours() > 0) {
                    row = sheet.createRow(rowNum);

                    cell = row.createCell((short) 0);
                    cell.setCellStyle(dateStyle);
                    cell.setCellValue(timelordTaskDay.getDate());

                    cell = row.createCell((short) 1);
                    cell.setCellValue(taskName);

                    cell = row.createCell((short) 2);
                    cell.setCellValue(timelordTaskDay.getHours());

                    cell = row.createCell((short) 3);
                    cell.setCellValue(timelordTaskDay.getNote());
                    rowNum++;
                }
            }

        }
    }
    return wb;
}

From source file:org.adempiere.impexp.AbstractExcelExporter.java

License:Open Source License

private HSSFCellStyle getHeaderStyle(int col) {
    String key = "header-" + col;
    HSSFCellStyle cs_header = m_styles.get(key);
    if (cs_header == null) {
        HSSFFont font_header = getFont(true);
        cs_header = m_workbook.createCellStyle();
        cs_header.setFont(font_header);// w  ww  . j a  va  2 s .com
        cs_header.setBorderLeft((short) 2);
        cs_header.setBorderTop((short) 2);
        cs_header.setBorderRight((short) 2);
        cs_header.setBorderBottom((short) 2);
        cs_header.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
        cs_header.setWrapText(true);
        m_styles.put(key, cs_header);
    }
    return cs_header;
}

From source file:org.beanfuse.transfer.exporter.writer.ExcelItemWriter.java

License:Open Source License

public ExcelItemWriter() {
    super();/*  w w w  .  ja  v a2  s  . c  o m*/
    dateStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
    timeStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
}

From source file:org.castafiore.groovy.Main.java

License:Open Source License

/**
 * @param args//from  www. j  a v  a2s .co  m
 */
public static void main(String[] args) throws Exception {
    //      Main m = new Main();
    //       m.startContainer();
    //       TutorialService tService = (TutorialService)m.getObject("tutorial");
    //       tService.testMethod();
    //       List<ASTNode> nodes = new AstBuilder().buildFromString("def w; def v; System.out.println(\"fsdfsdfs\");");
    //       
    //       
    //       for(ASTNode n : nodes){
    //          if(n instanceof BlockStatement){
    //             BlockStatement block = (BlockStatement)n;
    //            
    //             List<Statement> stms = block.getStatements();
    //             for(Statement s : stms){
    //                if(s instanceof ExpressionStatement){
    //                   ExpressionStatement expression = (ExpressionStatement)s;
    //                   Expression exp = expression.getExpression();
    //                   if(exp instanceof DeclarationExpression){
    //                      DeclarationExpression declaration = (DeclarationExpression)exp;
    //                      System.out.println( declaration.getLeftExpression().getText());
    //                   }
    //                   
    //                  //System.out.println(expression.getExpression().getClass().getName()); 
    //                   
    //                }
    //                //System.out.println(s.getClass().getName());
    //             }
    //          }
    //         // System.out.println(n.getText());
    //       }

    ///root/users/erevolution/Applications/e-Shop/erevolution/DefaultCashBook/entries/2012/
    //INSERT INTO WFS_FILE VALUES ('Account', '/root/users/erevolution/Applications/e-Shop/erevolution/DefaultCashBook/accounts/1351867186927', 'org.castafiore.accounting.Account', NULL, '2012-11-02 23:23:20', NULL, '2012-11-02 23:23:20', '\0', '1351867186927', 'erevolution', '*:users', 0, 0, '', NULL, 1, 1, '', 'Whenever there is a sales', NULL, 'Sales Account', NULL, NULL, NULL, NULL, NULL, 'SALES', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Income', 0.00, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '/root/users/erevolution/Applications/e-Shop/erevolution/DefaultCashBook/accounts', NULL);

    //      List<String> tier1 = new ArrayList<String>();
    //      List<String> tier2 = new ArrayList<String>();
    //      Sheet s = new HSSFWorkbook(new FileInputStream(new File("c:\\java\\erevolution\\tiers.xls"))).getSheetAt(0);
    //      for(int i =1; i <= s.getLastRowNum();i++){
    //         
    //         Row r = s.getRow(i);
    //         if(r != null && r.getCell(1) != null && r.getCell(1).getNumericCellValue() >0){
    //            //tier 1 agent for erevolution
    //            //System.out.println("insert into SECU_RELATIONSHIP values ("+(i+11000)+",'erevolution', 'Tier 2 Agent', '"+new Double(r.getCell(1).getNumericCellValue()).intValue()+"');");
    //            tier2.add(new Double(r.getCell(1).getNumericCellValue()).intValue() + "");
    //            
    //         }
    //         
    //         if(r != null && r.getCell(0) != null && r.getCell(0).getNumericCellValue() >0){
    //            //tier 1 agent for erevolution
    //            //System.out.println("insert into SECU_RELATIONSHIP values ("+(i+11000)+",'erevolution', 'Tier 2 Agent', '"+new Double(r.getCell(1).getNumericCellValue()).intValue()+"');");
    //            tier1.add(new Double(r.getCell(0).getNumericCellValue()).intValue() + "");
    //            
    //         }
    ////         if(s.getRow(i).getCell(0).getStringCellValue().equalsIgnoreCase("merchant"))
    ////            System.out.println("insert into SECU_RELATIONSHIP values ("+(i+10000)+",'erevolution', '"+s.getRow(i).getCell(3).getStringCellValue()+"', '"+s.getRow(i).getCell(1).getStringCellValue()+"');");
    //      }
    //FileOutputStream fout = new FileOutputStream(new File("c:\\java\\erevolution\\tiers.sql"));
    //FileWriter writer = new FileWriter(new File("c:\\java\\erevolution\\tiers.sql"));
    //int i = 12000;
    //      for(String t1 : tier1){
    //         for(String t2 : tier2){
    //            //writer.write(str)
    //            writer.write("insert into SECU_RELATIONSHIP values ("+(i++)+",'"+t1+"', 'Customer', '"+t2+"');\n");
    //            writer.write("insert into SECU_RELATIONSHIP values ("+(i++)+",'"+t2+"', 'Supplier', '"+t1+"');\n");
    //         }
    //      }

    //writer.flush();
    //writer.close();

    //      FileWriter writer = new FileWriter(new File("c:\\java\\erevolution\\tiers.sql"));
    //      tier2.add("erevolution");
    //      String[] accs = new String[]{"Sales:SALES","Purchases:PURCHASES", 
    //            "Travelling Expenses:TRAVELLING", "Salary:SALARY", "Tax:TAX", "Misc:MISC", 
    //            "Electricity:ELEC,Water,Telecom","NPS,NPF:NPS", "Bank charges and Interest:BNKCHGS","Loan:LOAN","Petty cash:PETTY", "Vehicle expenses:VEHICLE"};
    //      
    //      
    //      
    //      for(String t1 : tier1){
    //         
    //         for(String ss : accs){
    //            String[] parts = StringUtil.split(ss, ":");
    //            String code = parts[1];
    //            String acco = parts[0];
    //            String name = System.currentTimeMillis()+StringUtil.nextString(10);
    //            writer.write("INSERT INTO WFS_FILE VALUES ('Account', '/root/users/"+t1+"/Applications/e-Shop/"+t1+"/DefaultCashBook/accounts/"+name+ "', 'org.castafiore.accounting.Account', NULL, '2012-11-02 23:23:20', NULL, '2012-11-02 23:23:20', '\0', '1351867186927', '"+t1+"', '*:users', 0, 0, ' ', NULL, 1, 1, ' ', '"+acco+"', NULL, '"+acco+"', NULL, NULL, NULL, NULL, NULL, '"+code+"', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Income', 0.00, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '/root/users/"+t1+"/Applications/e-Shop/"+t1+"/DefaultCashBook/accounts', NULL);\n");
    //         }
    //         
    //         
    //         
    //      }
    //      
    //      for(String t1 : tier2){
    //         for(String ss : accs){
    //            String[] parts = StringUtil.split(ss, ":");
    //            String code = parts[1];
    //            String acco = parts[0];
    //            String name = System.currentTimeMillis()+StringUtil.nextString(10);
    //            writer.write("INSERT INTO WFS_FILE VALUES ('Account', '/root/users/"+t1+"/Applications/e-Shop/"+t1+"/DefaultCashBook/accounts/"+name+ "', 'org.castafiore.accounting.Account', NULL, '2012-11-02 23:23:20', NULL, '2012-11-02 23:23:20', '\0', '1351867186927', '"+t1+"', '*:users', 0, 0, ' ', NULL, 1, 1, ' ', '"+acco+"', NULL, '"+acco+"', NULL, NULL, NULL, NULL, NULL, '"+code+"', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Income', 0.00, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '/root/users/"+t1+"/Applications/e-Shop/"+t1+"/DefaultCashBook/accounts', NULL);\n");
    //         }
    //      }
    //      
    //      writer.flush();
    //      writer.close();
    Workbook hs = new HSSFWorkbook();
    Cell c = hs.createSheet().createRow(0).createCell(0);
    c.setCellValue("45");

    c.getCellStyle().setDataFormat(HSSFDataFormat.getBuiltinFormat("$#,##0_);($#,##0)"));
    DataFormatter d = new HSSFDataFormatter();

    System.out.println(d.formatCellValue(c));
    //MessageFormat.format(pattern, arguments)

}

From source file:org.displaytag.export.excel.ExcelUtils.java

License:Open Source License

/**
 * We cache the styles; they are expensive to construct.
 * @param properties props for this run/* ww w. j a va2  s . c  o m*/
 */
public void initCellStyles(TableProperties properties) {
    // Integer
    HSSFCellStyle style = getNewCellStyle();
    style.setAlignment(CellStyle.ALIGN_RIGHT);
    style.setDataFormat(
            HSSFDataFormat.getBuiltinFormat(properties.getProperty(ExcelUtils.EXCEL_FORMAT_INTEGER)));
    this.cellStyles.put(STYLE_INTEGER, style);

    // NUMBER
    style = getNewCellStyle();
    style.setAlignment(CellStyle.ALIGN_RIGHT);
    style.setDataFormat(
            HSSFDataFormat.getBuiltinFormat(properties.getProperty(ExcelUtils.EXCEL_FORMAT_NUMBER)));
    this.cellStyles.put(STYLE_NUMBER, style);

    // style = HSSFDataFormat.getBuiltinFormat("0.00%");

    // Date
    style = getNewCellStyle();
    style.setAlignment(CellStyle.ALIGN_RIGHT);
    style.setDataFormat(HSSFDataFormat.getBuiltinFormat(properties.getProperty(ExcelUtils.EXCEL_FORMAT_DATE)));
    style.setAlignment(CellStyle.ALIGN_RIGHT);
    this.cellStyles.put(STYLE_DATE, style);

    // Long text
    style = getNewCellStyle(); // http://jakarta.apache.org/poi/hssf/quick-guide.html#NewLinesInCells
    style.setWrapText(true);
    this.cellStyles.put(STYLE_LONGSTRING, style);

    // Regular text
    this.cellStyles.put(STYLE_STRING, getNewCellStyle());

    this.wrapAt = Integer.valueOf(properties.getProperty(ExcelUtils.EXCEL_WRAPAT));
}