Example usage for org.apache.poi.hssf.usermodel HSSFWorkbook createCellStyle

List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook createCellStyle

Introduction

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

Prototype

@Override
public HSSFCellStyle createCellStyle() 

Source Link

Document

Create a new Cell style and add it to the workbook's style table.

Usage

From source file:neg.JRViewerComercialProveedor.java

License:Open Source License

private static void crearCabeceraHojaExcel(HSSFWorkbook libro, HSSFSheet hoja) {
    HSSFRow fila = null;/*www  . j a  v a2s  . c  o  m*/
    HSSFCell celda = null;

    // Modificamos la fuente por defecto para que salga en negrita
    HSSFCellStyle cs = libro.createCellStyle();
    HSSFFont f = libro.createFont();
    f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    f.setColor(HSSFColor.WHITE.index);
    cs.setFont(f);
    //cs.setFillBackgroundColor(HSSFColor.GREEN.index);
    cs.setFillForegroundColor(HSSFColor.GREEN.index);
    cs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    cs.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
    cs.setBottomBorderColor(HSSFColor.BLACK.index);
    cs.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
    cs.setLeftBorderColor(HSSFColor.BLACK.index);
    cs.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
    cs.setRightBorderColor(HSSFColor.BLACK.index);
    cs.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
    cs.setTopBorderColor(HSSFColor.BLACK.index);

    cs.setAlignment(HSSFCellStyle.ALIGN_CENTER);

    // Creamos la cabecera de las columnas
    fila = hoja.createRow(0);

    celda = fila.createCell((short) 0);
    celda.setCellStyle(cs);
    HSSFRichTextString texto = new HSSFRichTextString("PROVEEDOR");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 0, (short) ((220 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 1);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("ENERO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 1, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 2);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("FEBRERO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 2, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 3);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("MARZO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 3, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 4);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("ABRIL");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 4, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 5);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("MAYO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 5, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 6);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("JUNIO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 6, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 7);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("JULIO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 7, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 8);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("AGOSTO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 8, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 9);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("SEPTIEMBRE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 9, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 10);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("OCTUBRE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 10, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 11);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("NOVIEMBRE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 11, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 12);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("DICIEMBRE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 12, (short) ((70 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 13);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("IMPORTE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 13, (short) ((90 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 14);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("% TURISMOS");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 14, (short) ((90 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 15);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("% FUNCIONAN");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 15, (short) ((90 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 16);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("%GRA UNITARIA");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 16, (short) ((90 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 17);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("NM.PEDIDOS");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 17, (short) ((90 * 2) / ((double) 1 / 20)));

}

From source file:neg.JRViewerComercialProveedor.java

License:Open Source License

private static void crearFilaHojaExcel(HSSFWorkbook libro, HSSFSheet hoja, int num_fila, ResultSet rs,
        HSSFCellStyle cs2, HSSFCellStyle cs3) throws SQLException, UnknownHostException {
    HSSFRow fila = null;//  ww  w.  ja v  a 2 s .c o m
    HSSFCell celda = null;
    HSSFRichTextString texto = null;
    int num_fila_aux = 2;
    while (rs.next()) {
        // Se crea una fila dentro de la hoja
        fila = hoja.createRow(num_fila);

        //Celda del Tarifa Cliente
        HSSFDataFormat format = libro.createDataFormat();

        HSSFCellStyle style = libro.createCellStyle();
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        style.setBottomBorderColor(HSSFColor.BLACK.index);
        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        style.setLeftBorderColor(HSSFColor.BLACK.index);
        style.setBorderRight(HSSFCellStyle.BORDER_THIN);
        style.setRightBorderColor(HSSFColor.BLACK.index);
        style.setBorderTop(HSSFCellStyle.BORDER_THIN);
        style.setTopBorderColor(HSSFColor.BLACK.index);

        style.setDataFormat(format.getFormat("#,##0"));

        //Celda de Proveedor
        celda = fila.createCell((short) 0);
        celda.setCellStyle(cs2);
        String proveedor = rs.getString("pr_nombre_fiscal");
        texto = new HSSFRichTextString(proveedor);
        celda.setCellStyle(cs3);
        celda.setCellValue(texto);

        celda.setCellStyle(style);

        //Celda de enero
        celda = fila.createCell((short) 1);
        celda.setCellStyle(cs3);
        double enero = rs.getDouble("enero_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(enero);
        style.setDataFormat(format.getFormat("00"));

        //Celda de febrero
        celda = fila.createCell((short) 2);
        double febrero = rs.getDouble("febrero_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(febrero);
        style.setDataFormat(format.getFormat("00"));

        //Celda de marzo
        celda = fila.createCell((short) 3);
        celda.setCellStyle(cs2);
        double marzo = rs.getDouble("marzo_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(marzo);
        style.setDataFormat(format.getFormat("00"));

        //Celda de abril
        celda = fila.createCell((short) 4);
        double abril = rs.getDouble("abril_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(abril);
        style.setDataFormat(format.getFormat("00"));

        //Celda de mayo
        celda = fila.createCell((short) 5);
        double mayo = rs.getDouble("mayo_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(mayo);
        style.setDataFormat(format.getFormat("00"));

        //Celda de junio
        celda = fila.createCell((short) 6);
        double junio = rs.getDouble("junio_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(junio);

        //Celda del julio
        celda = fila.createCell((short) 7);
        double julio = rs.getDouble("julio_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(julio);
        style.setDataFormat(format.getFormat("00"));

        //Celda de agosto
        celda = fila.createCell((short) 8);
        celda.setCellStyle(cs2);
        double agosto = rs.getDouble("agosto_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(agosto);
        style.setDataFormat(format.getFormat("00"));

        //Celda de septiembre
        celda = fila.createCell((short) 9);
        double septiembre = rs.getDouble("septiembre_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(septiembre);
        style.setDataFormat(format.getFormat("00"));

        //Celda de octubre
        celda = fila.createCell((short) 10);
        celda.setCellStyle(cs2);
        double octubre = rs.getDouble("octubre_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(octubre);
        style.setDataFormat(format.getFormat("00"));

        //Celda de noviembre
        celda = fila.createCell((short) 11);
        double noviembre = rs.getDouble("noviembre_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(noviembre);
        style.setDataFormat(format.getFormat("00"));

        //Celda de diciembre
        celda = fila.createCell((short) 12);
        celda.setCellStyle(cs2);
        double diciembre = rs.getDouble("diciembre_pr");
        celda.setCellStyle(cs3);
        celda.setCellValue(diciembre);
        style.setDataFormat(format.getFormat("00"));

        //Celda de la tarifa de Proveedor
        celda = fila.createCell((short) 13);
        celda.setCellValue(rs.getDouble("ta_proveedor"));

        //Celda de % turismo
        celda = fila.createCell((short) 14);
        celda.setCellStyle(cs3);
        double t_proveedor = Double.parseDouble(rs.getString("ta_proveedor"));
        double factor = Integer.parseInt(rs.getString("factor"));

        int num_pedido = Integer.parseInt(rs.getString("num_pedido"));
        String turismo = (!rs.getString("factor").equals("0"))
                ? new java.text.DecimalFormat("#,##0").format((factor / num_pedido) * 100).concat(" % ")
                : "0 % ";
        style.setDataFormat(format.getFormat("00.00"));
        celda.setCellValue(turismo);

        //Celda de % funciona
        celda = fila.createCell((short) 15);
        celda.setCellStyle(cs3);
        double funciona = Integer.parseInt(rs.getString("estado_ve"));

        String estado_ve = (!rs.getString("estado_ve").equals("0"))
                ? new java.text.DecimalFormat("#,##0").format((funciona / num_pedido) * 100).concat(" % ")
                : "0 % ";
        celda.setCellStyle(cs3);
        celda.setCellValue(estado_ve);

        //Celda % Gra Unitaria
        celda = fila.createCell((short) 16);
        celda.setCellStyle(cs3);
        double soporte = Integer.parseInt(rs.getString("soporte"));

        String grua = (!rs.getString("soporte").equals("0"))
                ? new java.text.DecimalFormat("#,##0").format((soporte / num_pedido) * 100).concat(" % ")
                : "0 % ";

        celda.setCellStyle(cs3);
        celda.setCellValue(grua);

        //Celda del num. pedido
        celda = fila.createCell((short) 17);
        celda.setCellStyle(cs3);
        celda.setCellValue(num_pedido);

        //Se incrementa el numero de fila
        num_fila++;
        num_fila_aux++;
    }
}

From source file:neg.JRViewerInformeUnitario.java

License:Open Source License

private void btnExcelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcelActionPerformed

    String queryInf = this.jasperPrint.getProperty("query");

    try {//from www. j  av  a2  s.c om
        // Se crea el libro excel
        HSSFWorkbook libro = new HSSFWorkbook();
        //Se crea la hoja
        HSSFSheet hoja = libro.createSheet("Informe");
        //Numero de fila de la hoja Excel
        int num_fila = 1;
        crearCabeceraHojaExcel(libro, hoja);

        HSSFCellStyle cs2 = libro.createCellStyle();
        cs2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        cs2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        cs2.setBottomBorderColor(HSSFColor.BLACK.index);
        cs2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        cs2.setLeftBorderColor(HSSFColor.BLACK.index);
        cs2.setBorderRight(HSSFCellStyle.BORDER_THIN);
        cs2.setRightBorderColor(HSSFColor.BLACK.index);
        cs2.setBorderTop(HSSFCellStyle.BORDER_THIN);
        cs2.setTopBorderColor(HSSFColor.BLACK.index);

        HSSFCellStyle cs3 = libro.createCellStyle();
        cs3.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        cs3.setBottomBorderColor(HSSFColor.BLACK.index);
        cs3.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        cs3.setLeftBorderColor(HSSFColor.BLACK.index);
        cs3.setBorderRight(HSSFCellStyle.BORDER_THIN);
        cs3.setRightBorderColor(HSSFColor.BLACK.index);
        cs3.setBorderTop(HSSFCellStyle.BORDER_THIN);
        cs3.setTopBorderColor(HSSFColor.BLACK.index);
        ResultSet rs = CSDesktop.datos.select(queryInf);

        crearFilaHojaExcel(libro, hoja, num_fila, rs, cs2, cs3);
        FileOutputStream elFichero = null;
        elFichero = new FileOutputStream("c:\\informe_unitario.xls");
        libro.write(elFichero);
        elFichero.close();
        elFichero.flush();
        String property = "java.io.tmpdir";
        String tempDir = System.getProperty(property);
        System.out.println("OS current temporary directory is " + tempDir);
        String file = new String("C:\\informe_unitario.xls");
        Process p = Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file);

    } catch (SQLException ex) {
        Logger.getLogger(CSResultBuscarPedidoNew.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnknownHostException ex) {
        Logger.getLogger(CSResultBuscarPedidoNew.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(CSResultBuscarPedidoNew.class.getName()).log(Level.SEVERE, null, ex);
    }

    //System.out.println("Vamoooooos: "+queryInf);

}

From source file:neg.JRViewerInformeUnitario.java

License:Open Source License

private static void crearCabeceraHojaExcel(HSSFWorkbook libro, HSSFSheet hoja) {
    HSSFRow fila = null;//w  w w  .  j  a  v  a 2 s .  co  m
    HSSFCell celda = null;

    // Modificamos la fuente por defecto para que salga en negrita
    HSSFCellStyle cs = libro.createCellStyle();
    HSSFFont f = libro.createFont();
    f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    f.setColor(HSSFColor.WHITE.index);
    cs.setFont(f);
    //cs.setFillBackgroundColor(HSSFColor.GREEN.index);
    cs.setFillForegroundColor(HSSFColor.GREEN.index);
    cs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    cs.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
    cs.setBottomBorderColor(HSSFColor.BLACK.index);
    cs.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
    cs.setLeftBorderColor(HSSFColor.BLACK.index);
    cs.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
    cs.setRightBorderColor(HSSFColor.BLACK.index);
    cs.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
    cs.setTopBorderColor(HSSFColor.BLACK.index);

    cs.setAlignment(HSSFCellStyle.ALIGN_RIGHT);

    // Creamos la cabecera de las columnas
    fila = hoja.createRow(0);

    celda = fila.createCell((short) 0);
    celda.setCellStyle(cs);
    HSSFRichTextString texto = new HSSFRichTextString("DATOS");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 0, (short) ((60 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 1);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("ENERO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 1, (short) ((60 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 2);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("FEBRERO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 2, (short) ((80 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 3);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("MARZO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 3, (short) ((200 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 4);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("ABRIL");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 4, (short) ((130 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 5);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("MAYO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 5, (short) ((60 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 6);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("JUNIO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 6, (short) ((130 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 7);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("JULIO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 7, (short) ((60 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 8);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("AGOSTO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 8, (short) ((80 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 9);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("SEPTIEMBRE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 9, (short) ((40 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 10);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("OCTUBRE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 10, (short) ((120 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 11);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("NOVIEMBRE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 11, (short) ((110 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 12);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("DICIEMBRE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 12, (short) ((130 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 13);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("M.G.");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 13, (short) ((130 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 14);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("M.G. PEDIDO");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 14, (short) ((130 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 15);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("NUM.PEDIDOS");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 15, (short) ((40 * 2) / ((double) 1 / 20)));

    celda = fila.createCell((short) 16);
    celda.setCellStyle(cs);
    texto = new HSSFRichTextString("IMPORTE");
    celda.setCellValue(texto);
    hoja.setColumnWidth((short) 16, (short) ((200 * 2) / ((double) 1 / 20)));

}

From source file:neg.JRViewerInformeUnitario.java

License:Open Source License

private static void crearFilaHojaExcel(HSSFWorkbook libro, HSSFSheet hoja, int num_fila, ResultSet rs,
        HSSFCellStyle cs2, HSSFCellStyle cs3) throws SQLException, UnknownHostException {
    HSSFRow fila = null;//from  ww w  . j a v a2 s.c  o  m
    HSSFCell celda = null;
    HSSFRichTextString texto = null;
    int num_fila_aux = 2;

    for (int i = 0; i < 4; i++) {
        //System.out.println();
        /*}
        while (rs.next())
        {*/
        if (i == 0) {
            // Se crea una fila dentro de la hoja
            fila = hoja.createRow(num_fila);

            //Celda de ttulo
            celda = fila.createCell((short) 0);
            celda.setCellStyle(cs2);
            texto = new HSSFRichTextString("Facturacin");
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de enero
            celda = fila.createCell((short) 1);
            String enero = rs.getString("enero");
            texto = new HSSFRichTextString(enero);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de febrero
            celda = fila.createCell((short) 2);
            String febrero = rs.getString("febrero");
            texto = new HSSFRichTextString(febrero);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de marzo
            celda = fila.createCell((short) 3);
            celda.setCellStyle(cs2);
            String marzo = rs.getString("marzo");
            texto = new HSSFRichTextString(marzo);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de abril
            celda = fila.createCell((short) 4);
            String abril = rs.getString("abril");
            texto = new HSSFRichTextString(abril);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de mayo
            celda = fila.createCell((short) 5);
            celda.setCellStyle(cs2);
            String mayo = rs.getString("mayo");
            texto = new HSSFRichTextString(mayo);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de junio
            celda = fila.createCell((short) 6);
            String junio = rs.getString("junio");
            texto = new HSSFRichTextString(junio);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda del julio
            celda = fila.createCell((short) 7);
            String julio = rs.getString("julio");
            texto = new HSSFRichTextString(julio);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de agosto
            celda = fila.createCell((short) 8);
            celda.setCellStyle(cs2);
            String agosto = rs.getString("agosto");
            texto = new HSSFRichTextString(agosto);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de septiembre
            celda = fila.createCell((short) 9);
            String septiembre = rs.getString("septiembre");
            texto = new HSSFRichTextString(septiembre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de octubre
            celda = fila.createCell((short) 10);
            celda.setCellStyle(cs2);
            String octubre = rs.getString("octubre");
            texto = new HSSFRichTextString(octubre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de noviembre
            celda = fila.createCell((short) 11);
            String noviembre = rs.getString("noviembre");
            texto = new HSSFRichTextString(noviembre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de diciembre
            celda = fila.createCell((short) 12);
            celda.setCellStyle(cs2);
            String diciembre = rs.getString("diciembre");
            texto = new HSSFRichTextString(diciembre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

        } else if (i == 1) {
            // Se crea una fila dentro de la hoja
            fila = hoja.createRow(num_fila);

            //Celda de ttulo
            celda = fila.createCell((short) 0);
            celda.setCellStyle(cs2);
            texto = new HSSFRichTextString("Margen pedido");
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de enero
            celda = fila.createCell((short) 1);
            String enero = rs.getString("mg_pe_enero");
            texto = new HSSFRichTextString(enero);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de febrero
            celda = fila.createCell((short) 2);
            String febrero = rs.getString("mg_pe_febrero");
            texto = new HSSFRichTextString(febrero);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de marzo
            celda = fila.createCell((short) 3);
            celda.setCellStyle(cs2);
            String marzo = rs.getString("mg_pe_marzo");
            texto = new HSSFRichTextString(marzo);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de abril
            celda = fila.createCell((short) 4);
            String abril = rs.getString("mg_pe_abril");
            texto = new HSSFRichTextString(abril);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de mayo
            celda = fila.createCell((short) 5);
            celda.setCellStyle(cs2);
            String mayo = rs.getString("mg_pe_mayo");
            texto = new HSSFRichTextString(mayo);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de junio
            celda = fila.createCell((short) 6);
            String junio = rs.getString("mg_pe_junio");
            texto = new HSSFRichTextString(junio);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda del julio
            celda = fila.createCell((short) 7);
            String julio = rs.getString("mg_pe_julio");
            texto = new HSSFRichTextString(julio);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de agosto
            celda = fila.createCell((short) 8);
            celda.setCellStyle(cs2);
            String agosto = rs.getString("mg_pe_agosto");
            texto = new HSSFRichTextString(agosto);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de septiembre
            celda = fila.createCell((short) 9);
            String septiembre = rs.getString("mg_pe_septiembre");
            texto = new HSSFRichTextString(septiembre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de octubre
            celda = fila.createCell((short) 10);
            celda.setCellStyle(cs2);
            String octubre = rs.getString("mg_pe_octubre");
            texto = new HSSFRichTextString(octubre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de noviembre
            celda = fila.createCell((short) 11);
            String noviembre = rs.getString("mg_pe_noviembre");
            texto = new HSSFRichTextString(noviembre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de diciembre
            celda = fila.createCell((short) 12);
            celda.setCellStyle(cs2);
            String diciembre = rs.getString("mg_pe_diciembre");
            texto = new HSSFRichTextString(diciembre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

        } else if (i == 2) {
            // Se crea una fila dentro de la hoja
            fila = hoja.createRow(num_fila);

            //Celda de ttulo
            celda = fila.createCell((short) 0);
            celda.setCellStyle(cs2);
            texto = new HSSFRichTextString("");
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

        } else if (i == 3) {
            // Se crea una fila dentro de la hoja
            fila = hoja.createRow(num_fila);
            //Celda de ttulo
            celda = fila.createCell((short) 0);
            celda.setCellStyle(cs2);
            texto = new HSSFRichTextString("NM. PEDIDOS");
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de enero
            celda = fila.createCell((short) 1);
            String enero = rs.getString("num_enero");
            texto = new HSSFRichTextString(enero);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de febrero
            celda = fila.createCell((short) 1);
            String febrero = rs.getString("num_febrero");
            texto = new HSSFRichTextString(febrero);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de marzo
            celda = fila.createCell((short) 2);
            celda.setCellStyle(cs2);
            String marzo = rs.getString("num_marzo");
            texto = new HSSFRichTextString(marzo);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de abril
            celda = fila.createCell((short) 3);
            String abril = rs.getString("num_abril");
            texto = new HSSFRichTextString(abril);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de mayo
            celda = fila.createCell((short) 4);
            celda.setCellStyle(cs2);
            String mayo = rs.getString("num_mayo");
            texto = new HSSFRichTextString(mayo);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de junio
            celda = fila.createCell((short) 5);
            String junio = rs.getString("num_junio");
            texto = new HSSFRichTextString(junio);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda del julio
            celda = fila.createCell((short) 6);
            String julio = rs.getString("num_julio");
            texto = new HSSFRichTextString(julio);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de agosto
            celda = fila.createCell((short) 7);
            celda.setCellStyle(cs2);
            String agosto = rs.getString("num_agosto");
            texto = new HSSFRichTextString(agosto);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de septiembre
            celda = fila.createCell((short) 8);
            String septiembre = rs.getString("num_septiembre");
            texto = new HSSFRichTextString(septiembre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de octubre
            celda = fila.createCell((short) 9);
            celda.setCellStyle(cs2);
            String octubre = rs.getString("num_octubre");
            texto = new HSSFRichTextString(octubre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de noviembre
            celda = fila.createCell((short) 10);
            String noviembre = rs.getString("num_noviembre");
            texto = new HSSFRichTextString(noviembre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de diciembre
            celda = fila.createCell((short) 11);
            celda.setCellStyle(cs2);
            String diciembre = rs.getString("num_diciembre");
            texto = new HSSFRichTextString(diciembre);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de MG
            celda = fila.createCell((short) 12);
            double t_cliente = Double.parseDouble(rs.getString("ta_cliente"));
            double t_proveedor = Double.parseDouble(rs.getString("ta_proveedor"));

            String porCientoPedido = new java.text.DecimalFormat("#,##0")
                    .format(((t_cliente - t_proveedor) / t_cliente) * 100).concat("% ");
            texto = new HSSFRichTextString(porCientoPedido);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda de mg pedido
            celda = fila.createCell((short) 13);
            String mg_pedido = rs.getString("mg_pedido");
            texto = new HSSFRichTextString(mg_pedido);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda del num. pedido
            celda = fila.createCell((short) 14);
            String num_pedido = rs.getString("num_pedido");
            texto = new HSSFRichTextString(num_pedido);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);

            //Celda del ta cliente
            celda = fila.createCell((short) 15);
            String ta_cliente = rs.getString("ta_cliente");
            texto = new HSSFRichTextString(ta_cliente);
            celda.setCellStyle(cs3);
            celda.setCellValue(texto);
        }
        //Celda de Tarifa Cliente
        HSSFDataFormat format = libro.createDataFormat();
        HSSFCellStyle style = libro.createCellStyle();
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        style.setBottomBorderColor(HSSFColor.BLACK.index);
        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        style.setLeftBorderColor(HSSFColor.BLACK.index);
        style.setBorderRight(HSSFCellStyle.BORDER_THIN);
        style.setRightBorderColor(HSSFColor.BLACK.index);
        style.setBorderTop(HSSFCellStyle.BORDER_THIN);
        style.setTopBorderColor(HSSFColor.BLACK.index);

        style.setDataFormat(format.getFormat("00"));

        celda.setCellStyle(style);

        //Se incrementa el numero de fila
        num_fila++;
        num_fila_aux++;
    }
}

From source file:net.algem.planning.export.PlanningExportService.java

License:Open Source License

/**
 *
 * @param wb workbook/*  w ww .j  a va 2s. co  m*/
 * @return a map, each key-value composed of a style name and a cell style
 */
private Map<String, CellStyle> createStyles(HSSFWorkbook wb) {
    Map<String, CellStyle> styles = new HashMap<>();

    HSSFFont nf = wb.createFont();
    nf.setFontName("monospace");

    HSSFFont bf = wb.createFont();
    bf.setFontName("monospace");
    bf.setBold(true);

    HSSFFont sf = wb.createFont();
    sf.setFontHeightInPoints((short) 8);
    sf.setFontName("monospace");

    CellStyle style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setWrapText(true);
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    styles.put("header", style);

    //LEFT HEADER
    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
    style.setWrapText(true);
    style.setFont(bf);
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setBorderTop(CellStyle.BORDER_THIN);
    style.setBorderBottom(CellStyle.BORDER_DOTTED);
    styles.put("hour", style);

    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
    style.setWrapText(false);
    style.setFont(sf);
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setBorderTop(CellStyle.BORDER_DOTTED);
    style.setBorderBottom(CellStyle.BORDER_THIN);
    styles.put("hour-quarter", style);

    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
    style.setWrapText(false);
    style.setFont(sf);
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setBorderTop(CellStyle.BORDER_DASHED);
    style.setBorderBottom(CellStyle.BORDER_THIN);
    styles.put("hour-half", style);

    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
    style.setWrapText(true);
    style.setFont(nf);
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setBorderTop(CellStyle.BORDER_THIN);
    style.setBorderBottom(CellStyle.BORDER_THIN);
    styles.put("hour-last", style);

    return styles;
}

From source file:net.algem.planning.export.PlanningExportService.java

License:Open Source License

/**
 *
 * @param wb workbook/*  w w w .j  av  a2s  . c  om*/
 * @param schedule current schedule
 * @param cache styles cache
 * @return a cell style
 */
private CellStyle getCourseStyle(HSSFWorkbook wb, ScheduleObject schedule,
        Map<java.awt.Color, CellStyle> cache) {
    java.awt.Color color = colorizer.getScheduleColor(schedule);
    CellStyle cachedStyle = cache.get(color);
    if (cachedStyle != null) {
        return cachedStyle;
    } else {
        CellStyle style = wb.createCellStyle();
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
        style.setWrapText(true);
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        //the cell is painted with a pattern that consists of foreground and background pixels.
        //If you use SOLID_FOREGROUND, just the foreground pixel are visible.
        //This color is different from the color used to render text, which is set with the font
        style.setFillForegroundColor(getColorIndex(wb, color));

        // Unused because font is applied as richTextString property
        /*java.awt.Color textColor = colorizer.getTextColor(schedule);
        HSSFFont font = wb.createFont();
        font.setColor(getColorIndex(wb, textColor));
        style.setFont(font);
        cache.put(color, style);*/
        return style;
    }
}

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./* w w  w .j av a 2 s  . 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.//from  w ww. ja va 2  s. c o  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:net.mindengine.oculus.frontend.service.report.ExcelReport.java

License:Open Source License

public void writeDocument(SavedRun savedRun, List<TestRunSearchData> testRuns) throws IOException {
    HSSFWorkbook workBook = new HSSFWorkbook();

    HSSFSheet sheet = workBook.createSheet();
    HSSFRow headerRow = sheet.createRow(0);
    HSSFCellStyle columnHeaderStyle = workBook.createCellStyle();
    columnHeaderStyle.setBorderTop((short) 1);
    columnHeaderStyle.setBorderLeft((short) 1);
    columnHeaderStyle.setBorderRight((short) 1);
    columnHeaderStyle.setBorderBottom((short) 1);
    columnHeaderStyle.setFillForegroundColor(HSSFColor.LIGHT_BLUE.index);
    columnHeaderStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

    HSSFCell cell;//from w w w .j  ava2 s.  co m

    cell = headerRow.createCell((short) 0);
    cell.setCellValue(new HSSFRichTextString("Log"));
    cell.setCellStyle(columnHeaderStyle);

    cell = headerRow.createCell((short) 1);
    cell.setCellValue(new HSSFRichTextString("Test Run Id"));
    cell.setCellStyle(columnHeaderStyle);

    cell = headerRow.createCell((short) 2);
    cell.setCellValue(new HSSFRichTextString("Test Name"));
    cell.setCellStyle(columnHeaderStyle);

    cell = headerRow.createCell((short) 3);
    cell.setCellValue(new HSSFRichTextString("Project"));
    cell.setCellStyle(columnHeaderStyle);

    cell = headerRow.createCell((short) 4);
    cell.setCellValue(new HSSFRichTextString("Status"));
    cell.setCellStyle(columnHeaderStyle);

    cell = headerRow.createCell((short) 5);
    cell.setCellValue(new HSSFRichTextString("Designer"));
    cell.setCellStyle(columnHeaderStyle);

    cell = headerRow.createCell((short) 6);
    cell.setCellValue(new HSSFRichTextString("Runner"));
    cell.setCellStyle(columnHeaderStyle);

    cell = headerRow.createCell((short) 7);
    cell.setCellValue(new HSSFRichTextString("Start Time"));
    cell.setCellStyle(columnHeaderStyle);

    int id = 0;

    HSSFCellStyle rowPassedStyle = workBook.createCellStyle();
    rowPassedStyle.setBorderTop((short) 1);
    rowPassedStyle.setBorderLeft((short) 1);
    rowPassedStyle.setBorderRight((short) 1);
    rowPassedStyle.setBorderBottom((short) 1);
    rowPassedStyle.setFillForegroundColor(HSSFColor.LIGHT_GREEN.index);
    rowPassedStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    rowPassedStyle.setWrapText(true);

    HSSFCellStyle rowWarnStyle = workBook.createCellStyle();
    rowWarnStyle.setBorderTop((short) 1);
    rowWarnStyle.setBorderLeft((short) 1);
    rowWarnStyle.setBorderRight((short) 1);
    rowWarnStyle.setBorderBottom((short) 1);
    rowWarnStyle.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
    rowWarnStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    rowWarnStyle.setWrapText(true);

    HSSFCellStyle rowFailStyle = workBook.createCellStyle();
    rowFailStyle.setBorderTop((short) 1);
    rowFailStyle.setBorderLeft((short) 1);
    rowFailStyle.setBorderRight((short) 1);
    rowFailStyle.setBorderBottom((short) 1);
    rowFailStyle.setFillForegroundColor(HSSFColor.RED.index);
    rowFailStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    rowFailStyle.setWrapText(true);

    HSSFCellStyle cellStyle = null;
    for (TestRunSearchData run : testRuns) {
        if (run.getTestRunStatus().equals("PASSED")) {
            cellStyle = rowPassedStyle;
        } else if (run.getTestRunStatus().equals("FAILED")) {
            cellStyle = rowFailStyle;
        } else
            cellStyle = rowWarnStyle;
        id++;
        HSSFRow row = sheet.createRow(id);

        cell = row.createCell((short) 0);
        cell.setCellValue(new HSSFRichTextString(
                "http://" + config.getOculusServerUrl() + "/report/report-" + run.getTestRunId()));
        cell.setCellStyle(cellStyle);

        cell = row.createCell((short) 1);
        cell.setCellValue(run.getTestRunId());
        cell.setCellStyle(cellStyle);

        cell = row.createCell((short) 2);
        cell.setCellValue(new HSSFRichTextString(run.getFetchTestName()));
        cell.setCellStyle(cellStyle);

        cell = row.createCell((short) 3);
        cell.setCellValue(new HSSFRichTextString(run.getFetchProjectName()));
        cell.setCellStyle(cellStyle);

        cell = row.createCell((short) 4);
        cell.setCellValue(new HSSFRichTextString(run.getTestRunStatus()));
        cell.setCellStyle(cellStyle);

        cell = row.createCell((short) 5);
        cell.setCellValue(new HSSFRichTextString(run.getDesignerName()));
        cell.setCellStyle(cellStyle);

        cell = row.createCell((short) 6);
        cell.setCellValue(new HSSFRichTextString(run.getRunnerName()));
        cell.setCellStyle(cellStyle);

        cell = row.createCell((short) 7);
        SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy  HH:mm:ss");
        cell.setCellValue(new HSSFRichTextString(sdf.format(run.getTestRunStartTime())));
        cell.setCellStyle(cellStyle);

    }

    workBook.write(outputStream);

}