Example usage for org.apache.poi.hssf.usermodel HSSFFont BOLDWEIGHT_BOLD

List of usage examples for org.apache.poi.hssf.usermodel HSSFFont BOLDWEIGHT_BOLD

Introduction

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

Prototype

short BOLDWEIGHT_BOLD

To view the source code for org.apache.poi.hssf.usermodel HSSFFont BOLDWEIGHT_BOLD.

Click Source Link

Document

Bold boldness (bold)

Usage

From source file:net.sf.infrared.web.report.ExcelSummaryReport.java

License:Apache License

private void setUpSubHeadingStyle() {
    subHeadingStyle = wb.createCellStyle();
    HSSFFont subHeadingFont = wb.createFont();
    subHeadingFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    subHeadingFont.setFontHeightInPoints((short) 12);
    subHeadingStyle.setFont(subHeadingFont);
}

From source file:net.sf.infrared.web.report.ExcelSummaryReport.java

License:Apache License

private void setUpMainHeadingStyle() {
    mainHeadingStyle = wb.createCellStyle();
    HSSFFont mainHeadingFont = wb.createFont();
    mainHeadingFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    mainHeadingFont.setFontHeightInPoints((short) 14);
    mainHeadingStyle.setFont(mainHeadingFont);
}

From source file:net.sf.jasperreports.engine.export.JRXlsExporter.java

License:Open Source License

/**
 *
 *//*from   w  w w  . ja  v a2s  .co m*/
protected HSSFFont getLoadedFont(JRFont font, short forecolor, Map<Attribute, Object> attributes,
        Locale locale) {
    HSSFFont cellFont = null;

    String fontName = font.getFontName();

    FontInfo fontInfo = FontUtil.getInstance(jasperReportsContext).getFontInfo(fontName, locale);
    if (fontInfo != null) {
        //fontName found in font extensions
        FontFamily family = fontInfo.getFontFamily();
        String exportFont = family.getExportFont(getExporterKey());
        if (exportFont != null) {
            fontName = exportFont;
        }
    }

    short superscriptType = HSSFFont.SS_NONE;

    if (attributes != null && attributes.get(TextAttribute.SUPERSCRIPT) != null) {
        Object value = attributes.get(TextAttribute.SUPERSCRIPT);
        if (TextAttribute.SUPERSCRIPT_SUPER.equals(value)) {
            superscriptType = HSSFFont.SS_SUPER;
        } else if (TextAttribute.SUPERSCRIPT_SUB.equals(value)) {
            superscriptType = HSSFFont.SS_SUB;
        }

    }
    boolean isFontSizeFixEnabled = getCurrentItemConfiguration().isFontSizeFixEnabled();
    for (int i = 0; i < loadedFonts.size(); i++) {
        HSSFFont cf = (HSSFFont) loadedFonts.get(i);

        short fontSize = (short) font.getFontsize();
        if (isFontSizeFixEnabled) {
            fontSize -= 1;
        }
        if (cf.getFontName().equals(fontName) && (cf.getColor() == forecolor)
                && (cf.getFontHeightInPoints() == fontSize)
                && ((cf.getUnderline() == HSSFFont.U_SINGLE) ? (font.isUnderline()) : (!font.isUnderline()))
                && (cf.getStrikeout() == font.isStrikeThrough())
                && ((cf.getBoldweight() == HSSFFont.BOLDWEIGHT_BOLD) ? (font.isBold()) : (!font.isBold()))
                && (cf.getItalic() == font.isItalic()) && (cf.getTypeOffset() == superscriptType)) {
            cellFont = cf;
            break;
        }
    }

    if (cellFont == null) {
        cellFont = workbook.createFont();

        cellFont.setFontName(fontName);
        cellFont.setColor(forecolor);

        short fontSize = (short) font.getFontsize();
        if (isFontSizeFixEnabled) {
            fontSize -= 1;
        }
        cellFont.setFontHeightInPoints(fontSize);

        if (font.isUnderline()) {
            cellFont.setUnderline(HSSFFont.U_SINGLE);
        }
        if (font.isStrikeThrough()) {
            cellFont.setStrikeout(true);
        }
        if (font.isBold()) {
            cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        }
        if (font.isItalic()) {
            cellFont.setItalic(true);
        }

        cellFont.setTypeOffset(superscriptType);
        loadedFonts.add(cellFont);
    }

    return cellFont;
}

From source file:net.sf.jasperreports.engine.export.JRXlsMetadataExporter.java

License:Open Source License

/**
 *
 *//*from w  w  w  .  j  av a2  s  .  c  om*/
protected HSSFFont getLoadedFont(JRFont font, short forecolor, Map<Attribute, Object> attributes,
        Locale locale) {

    HSSFFont cellFont = null;
    String fontName = font.getFontName();
    FontInfo fontInfo = FontUtil.getInstance(jasperReportsContext).getFontInfo(fontName, locale);
    if (fontInfo != null) {
        //fontName found in font extensions
        FontFamily family = fontInfo.getFontFamily();
        String exportFont = family.getExportFont(getExporterKey());
        if (exportFont != null) {
            fontName = exportFont;
        }
    }

    boolean isFontSizeFixEnabled = getCurrentItemConfiguration().isFontSizeFixEnabled();

    short superscriptType = HSSFFont.SS_NONE;

    if (attributes != null && attributes.get(TextAttribute.SUPERSCRIPT) != null) {
        Object value = attributes.get(TextAttribute.SUPERSCRIPT);
        if (TextAttribute.SUPERSCRIPT_SUPER.equals(value)) {
            superscriptType = HSSFFont.SS_SUPER;
        } else if (TextAttribute.SUPERSCRIPT_SUB.equals(value)) {
            superscriptType = HSSFFont.SS_SUB;
        }
    }
    for (int i = 0; i < loadedFonts.size(); i++) {
        HSSFFont cf = (HSSFFont) loadedFonts.get(i);
        short fontSize = (short) font.getFontsize();
        if (isFontSizeFixEnabled) {
            fontSize -= 1;
        }
        if (cf.getFontName().equals(fontName) && (cf.getColor() == forecolor)
                && (cf.getFontHeightInPoints() == fontSize)
                && ((cf.getUnderline() == HSSFFont.U_SINGLE) ? (font.isUnderline()) : (!font.isUnderline()))
                && (cf.getStrikeout() == font.isStrikeThrough())
                && ((cf.getBoldweight() == HSSFFont.BOLDWEIGHT_BOLD) ? (font.isBold()) : (!font.isBold()))
                && (cf.getItalic() == font.isItalic()) && (cf.getTypeOffset() == superscriptType)) {
            cellFont = cf;
            break;
        }
    }

    if (cellFont == null) {

        cellFont = workbook.createFont();
        cellFont.setFontName(fontName);
        cellFont.setColor(forecolor);
        short fontSize = (short) font.getFontsize();
        if (isFontSizeFixEnabled) {
            fontSize -= 1;
        }
        cellFont.setFontHeightInPoints(fontSize);

        if (font.isUnderline()) {
            cellFont.setUnderline(HSSFFont.U_SINGLE);
        }
        if (font.isStrikeThrough()) {
            cellFont.setStrikeout(true);
        }
        if (font.isBold()) {
            cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        }
        if (font.isItalic()) {
            cellFont.setItalic(true);
        }

        cellFont.setTypeOffset(superscriptType);
        loadedFonts.add(cellFont);
    }
    return cellFont;
}

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

License:Open Source License

private HSSFFont getFont(boolean isHeader) {
    HSSFFont font = null;/*from   ww  w  . j a  va 2 s .c  o m*/
    if (isHeader) {
        if (m_fontHeader == null) {
            m_fontHeader = m_workbook.createFont();
            m_fontHeader.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        }
        font = m_fontHeader;
    } else if (isFunctionRow()) {
        font = m_workbook.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        font.setItalic(true);
    } else {
        if (m_fontDefault == null) {
            m_fontDefault = m_workbook.createFont();
        }
        font = m_fontDefault;
    }
    return font;
}

From source file:org.anyframe.logmanager.web.LogManagerController.java

License:Apache License

/**
 * log data export for excel file type/*from ww w .j  a v  a 2  s .  c  o m*/
 * 
 * @param searchCondition
 * @param model
 * @param request
 * @return
 * @throws Exception
 */
@RequestMapping(params = "method=xlsExport")
public void xlsExport(LogSearchCondition searchCondition, Model model, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    searchCondition.setPageIndex(-1);
    searchCondition.setCollection(searchCondition.getRepositoryName());

    String fileName = null;
    String sDate = null;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", new Locale("ko_KR"));
    sDate = sdf.format(new Date());
    StringBuffer sb = new StringBuffer();
    sb.append(searchCondition.getAppName().substring(searchCondition.getAppName().lastIndexOf("/") + 1));
    sb.append("_").append(searchCondition.getCollection()).append("_").append(sDate).append(".xls");
    fileName = sb.toString();

    SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-ddHHmm");
    logger.debug("from:{}",
            searchCondition.getFromDate() + searchCondition.getFromHour() + searchCondition.getFromMinute());
    logger.debug("to:{}",
            searchCondition.getToDate() + searchCondition.getToHour() + searchCondition.getToMinute());
    if (searchCondition.isUseFromDate())
        searchCondition.setFromDateTime(dateTimeFormat.parse(searchCondition.getFromDate()
                + searchCondition.getFromHour() + searchCondition.getFromMinute()));
    if (searchCondition.isUseToDate())
        searchCondition.setToDateTime(dateTimeFormat.parse(
                searchCondition.getToDate() + searchCondition.getToHour() + searchCondition.getToMinute()));

    List<LogDataMap> resultList = service.searchAnalysisLog(searchCondition);

    response.reset();
    response.setContentType("application/x-msexcel;charset=MS949");
    // response.setContentType("application/octet-stream");
    String userAgent = request.getHeader("User-Agent");

    if (userAgent.indexOf("MSIE 5.5") > -1) {
        response.setHeader("Content-Disposition", "filename=\"" + URLEncoder.encode(fileName, "UTF-8") + "\";");
    } else if (userAgent.indexOf("MSIE") > -1) {
        response.setHeader("Content-Disposition",
                "attachment; filename=\"" + java.net.URLEncoder.encode(fileName, "UTF-8") + "\";");
    } else {
        response.setHeader("Content-Disposition",
                "attachment; filename=\"" + new String(fileName.getBytes("euc-kr"), "latin1") + "\";");
    }
    response.setHeader("Content-Description", "JSP Generated Data");
    response.setHeader("Content-Transfer-Encoding", "binary;");
    response.setHeader("Pragma", "no-cache;");
    response.setHeader("Expires", "-1;");

    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet(fileName);

    OutputStream fileOut = null;
    try {
        fileOut = response.getOutputStream();
        HSSFRow row = null;
        HSSFRow headerRow = null;

        HSSFDataFormat df = workbook.createDataFormat();

        HSSFCellStyle headerStyle = workbook.createCellStyle();
        HSSFFont boldFont = workbook.createFont();
        boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        headerStyle.setFont(boldFont);
        headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);

        HSSFCellStyle style = workbook.createCellStyle();
        style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

        HSSFCellStyle dateStyle = workbook.createCellStyle();
        dateStyle.setDataFormat(df.getFormat("yyyy-mm-dd h:mm:ss.000"));
        dateStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
        dateStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

        HSSFCellStyle messageStyle = workbook.createCellStyle();
        messageStyle.setWrapText(true);
        messageStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
        messageStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

        HSSFCell cell;
        HSSFCell headerCell;

        short width = 265;

        Iterator<String> j = null;
        String key = null;
        int cellIndex = 0;
        int listSize = 0;

        String level = null;
        Date timestamp = null;
        String message = null;

        if (resultList != null) {
            listSize = resultList.size();
            for (int i = 0; i < listSize; i++) {
                LogDataMap log = (LogDataMap) resultList.get(i);
                if (i == 0) {
                    headerRow = sheet.createRow(i); // level header
                    sheet.setColumnWidth(0, 7 * width);
                    headerCell = headerRow.createCell(0);
                    HSSFRichTextString headerValue = new HSSFRichTextString("level");
                    headerCell.setCellValue(headerValue);
                    headerCell.setCellStyle(headerStyle);

                    headerCell = headerRow.createCell(1); // time stamp header
                    sheet.setColumnWidth(1, 24 * width);
                    headerValue = new HSSFRichTextString("timestamp");
                    headerCell.setCellValue(headerValue);
                    headerCell.setCellStyle(headerStyle);

                    headerCell = headerRow.createCell(2); // message header
                    sheet.setColumnWidth(2, 70 * width);
                    headerValue = new HSSFRichTextString("message");
                    headerCell.setCellValue(headerValue);
                    headerCell.setCellStyle(headerStyle);
                }

                row = sheet.createRow(i + 1);

                // level
                level = (String) log.get("level");
                cell = row.createCell(0);
                cell.setCellStyle(style);
                cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                cell.setCellValue(level);

                // timestamp
                timestamp = (Date) log.get("timestamp");
                cell = row.createCell(1);
                cell.setCellStyle(dateStyle);
                cell.setCellValue(timestamp);

                // message
                message = (String) log.get("message");
                HSSFRichTextString messageValue = new HSSFRichTextString(message);
                cell = row.createCell(2);
                cell.setCellStyle(messageStyle);
                cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                cell.setCellValue(messageValue);

                cellIndex = 3;
                j = log.keySet().iterator();
                while (j.hasNext()) {
                    key = j.next();
                    if ("_id".equals(key) || "message".equals(key) || "timestamp".equals(key)
                            || "level".equals(key)) {
                        continue;
                    }
                    //logger.debug("key=" + key);
                    if (i == 0) {
                        sheet.setColumnWidth(cellIndex, 20 * width);

                        headerCell = headerRow.createCell(cellIndex);
                        HSSFRichTextString headerValue = new HSSFRichTextString(key);
                        headerCell.setCellValue(headerValue);
                        headerCell.setCellStyle(headerStyle);
                    }
                    cell = row.createCell(cellIndex);
                    Object value = log.get(key);
                    if (value instanceof Date) {
                        cell.setCellStyle(dateStyle);
                        cell.setCellValue((Date) value);
                    } else {
                        cell.setCellStyle(style);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                        cell.setCellValue((String) log.get(key));
                    }

                    cellIndex++;
                }
            }
            workbook.write(fileOut);
        }
    } catch (Exception e) {
        throw e;
    } finally {
        try {
            if (fileOut != null) {
                fileOut.flush();
                fileOut.close();
            }
        } catch (IOException ex) {
            logger.warn(ex.getMessage(), ex);
        }
    }
}

From source file:org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPFont.java

License:Apache License

/**
 * Override of Initialize() implementation
 * @param attributes the array of Attribute instances; may be empty, will
 *                  never be null/*w  w w .ja v  a2  s. com*/
 * @param parent the parent ElementProcessor; may be null
 * @exception IOException if anything is wrong
 */
public void initialize(final Attribute[] attributes, final ElementProcessor parent) throws IOException {
    super.initialize(attributes, parent);
    EPStyle pstyle = (EPStyle) parent;
    if (pstyle.isValid()) {
        Hashtable colorhash = pstyle.getColorHash();
        HSSFColor color = null;

        HSSFCellStyle style = pstyle.getStyle();
        //style.setFillForegroundColor(
        Workbook workbook = getWorkbook();
        HSSFFont font = workbook.createFont();
        style.setFont(font);
        font.setFontHeightInPoints((short) getUnit());
        //font.setFontName(getFont());
        font.setItalic(getItalic());
        if (getBold()) {
            font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        } else {
            font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
        }
        font.setUnderline((byte) getUnderline());
        font.setStrikeout(getStrikeThrough());

        color = (HSSFColor) colorhash.get(pstyle.getForegroundColor().toString());
        //System.out.println(pstyle.getForegroundColor().toString());
        if (color == null)
            color = new HSSFColor.BLACK();
        font.setColor(color.getIndex());
        hssfFont = font;
    }
}

From source file:org.clickframes.renderer.RequirementsGenerator.java

License:Open Source License

public static HSSFCellStyle createHeaderColumnStyle(HSSFWorkbook wb) {
    HSSFCellStyle cellStyle = wb.createCellStyle();
    HSSFFont font = wb.createFont();/*from  ww  w  . jav  a  2s. c o m*/
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    cellStyle.setFont(font);

    return cellStyle;
}

From source file:org.cyberoam.iview.servlets.ExcelFileGenerator.java

License:Open Source License

void getWorkBook(ResultSetWrapper rsw, ReportBean reportBean, HSSFWorkbook wb) {
    try {//from  w w w. jav  a  2 s.com
        ReportColumnBean[] reportColumns = (ReportColumnBean[]) ReportColumnBean
                .getReportColumnsByReportID(reportBean.getReportId()).toArray(new ReportColumnBean[0]);
        HSSFSheet newSheet = wb.createSheet(reportBean.getTitle());
        HSSFRow row;
        HSSFCell cell;

        HSSFCellStyle cellStyle = wb.createCellStyle();
        HSSFFont fontStyle = wb.createFont();

        fontStyle.setFontHeightInPoints((short) 10);
        fontStyle.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        cellStyle.setFont(fontStyle);

        // getting number of records & fields for report
        rsw.last();
        int rowCount = rsw.getRow();
        int colCount = reportColumns.length;

        //For Freezing the first row
        newSheet.createFreezePane(0, 1, 0, 1);

        // Adding column headings to Excel
        row = newSheet.createRow((short) 0);
        for (int cCount = 0; cCount < colCount; cCount++) {
            cell = row.createCell(cCount);
            cell.setCellStyle(cellStyle);
            cell.setCellValue(reportColumns[cCount].getColumnName());
        }
        //Adding data for each record to Excel
        rsw.first();
        for (int rcount = 1; rcount <= rowCount; rcount++) {
            row = newSheet.createRow(rcount);
            for (int cCount = 0; cCount < colCount; cCount++) {
                String data = rsw.getString(reportColumns[cCount].getDbColumnName());
                cell = row.createCell(cCount);
                newSheet.autoSizeColumn((short) cCount);
                if (reportColumns[cCount].getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) {
                    data = ByteInUnit.getBytesInUnit(rsw.getLong(reportColumns[cCount].getDbColumnName()));
                } else if (reportColumns[cCount].getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING
                        && data.indexOf(':') != -1) {
                    String xdata = ProtocolBean.getProtocolNameById(
                            Integer.parseInt(rsw.getString(reportColumns[cCount].getDbColumnName()).substring(0,
                                    data.indexOf(':'))));
                    data = xdata + rsw.getString(reportColumns[cCount].getDbColumnName())
                            .substring(data.indexOf(':'), data.length());
                }
                // Setting value to the cell
                if (cCount == 0 && (data == null || "".equalsIgnoreCase(data)))
                    data = "N/A";
                if (reportColumns[cCount].getColumnFormat() == TabularReportConstants.PERCENTAGE_FORMATTING) {
                    try {
                        cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                        cell.setCellValue(Double.parseDouble(data));
                    } catch (NumberFormatException e) {
                        cell.setCellValue(data);
                    }
                } else if (rsw.getMetaData().getColumnTypeName(cCount + 1).equalsIgnoreCase("numeric")
                        && reportColumns[cCount].getColumnFormat() != TabularReportConstants.BYTE_FORMATTING) {
                    try {
                        cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                        cell.setCellValue(Integer.parseInt(data));
                    } catch (NumberFormatException e) {
                        cell.setCellValue(data);
                    }
                } else {
                    cell.setCellValue(data);
                }
            }
            rsw.next();
        }

    } catch (Exception e) {
        CyberoamLogger.appLog.error("***Error in getWorkbook function***" + e, e);
    }
}

From source file:org.deployom.core.AuditService.java

License:Open Source License

public HSSFWorkbook saveAudit() {

    // Create book
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFCreationHelper creationHelper = workbook.getCreationHelper();

    // Default Style
    HSSFCellStyle style = workbook.createCellStyle();
    style.setWrapText(true);/* www .j a  v a2  s .  c om*/
    HSSFFont font = workbook.createFont();
    font.setFontName("Courier New");
    style.setFont(font);
    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    style.setBorderTop(HSSFCellStyle.BORDER_THIN);
    style.setBorderRight(HSSFCellStyle.BORDER_THIN);
    style.setBorderLeft(HSSFCellStyle.BORDER_THIN);

    // Header Style
    HSSFCellStyle styleHeader = workbook.createCellStyle();
    styleHeader.cloneStyleFrom(style);
    styleHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    font = workbook.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    font.setColor(HSSFColor.WHITE.index);
    styleHeader.setFillForegroundColor(IndexedColors.BLACK.getIndex());
    styleHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    styleHeader.setFont(font);

    // Error Style
    HSSFCellStyle styleError = workbook.createCellStyle();
    styleError.cloneStyleFrom(style);
    styleError.setFillForegroundColor(IndexedColors.CORAL.getIndex());
    styleError.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    styleError.setWrapText(true);

    // Link Style
    HSSFCellStyle styleLink = workbook.createCellStyle();
    styleLink.cloneStyleFrom(style);
    font = workbook.createFont();
    font.setUnderline(HSSFFont.U_SINGLE);
    font.setColor(IndexedColors.BLUE.getIndex());
    styleLink.setFont(font);

    // Create Summary
    HSSFSheet summarySheet = workbook.createSheet("Summary");
    int summaryRownum = 0;
    int summaryCellnum = 0;

    //Create a new row in current sheet
    Row summaryRow = summarySheet.createRow(summaryRownum++);

    // 0
    Cell summaryCell = summaryRow.createCell(summaryCellnum++);
    summaryCell.setCellValue("Job");
    summaryCell.setCellStyle(styleHeader);

    // 1
    summaryCell = summaryRow.createCell(summaryCellnum++);
    summaryCell.setCellValue("Finished");
    summaryCell.setCellStyle(styleHeader);

    // 2
    summaryCell = summaryRow.createCell(summaryCellnum++);
    summaryCell.setCellValue("Errors");
    summaryCell.setCellStyle(styleHeader);

    for (Job job : releaseService.getJobs()) {

        // Open Job
        JobService jobService = new JobService(siteService.getSiteName(), job.getJobName());

        // Create Sheet
        HSSFSheet sheet = workbook.createSheet(job.getJobName());

        int rownum = 0;
        int cellnum = 0;
        int errors = 0;

        //Create a new row in current sheet
        Row row = sheet.createRow(rownum++);

        // 0
        Cell cell = row.createCell(cellnum++);
        cell.setCellValue("Host");
        cell.setCellStyle(styleHeader);

        // 1
        cell = row.createCell(cellnum++);
        cell.setCellValue("Service");
        cell.setCellStyle(styleHeader);

        // 2
        cell = row.createCell(cellnum++);
        cell.setCellValue("Command");
        cell.setCellStyle(styleHeader);

        // 3
        cell = row.createCell(cellnum++);
        cell.setCellValue("Executable");
        cell.setCellStyle(styleHeader);

        // 4
        cell = row.createCell(cellnum++);
        cell.setCellValue("Error");
        cell.setCellStyle(styleHeader);

        // 5
        cell = row.createCell(cellnum++);
        cell.setCellValue("Output");
        cell.setCellStyle(styleHeader);

        // Check all hosts
        for (Host host : jobService.getHosts()) {

            // Check all services
            for (Service service : host.getServices()) {

                // Get a Commands
                for (Command command : service.getCommands()) {

                    //Create a new row in current sheet
                    row = sheet.createRow(rownum++);
                    cellnum = 0;

                    // 0
                    cell = row.createCell(cellnum++);
                    cell.setCellValue(host.getHostName());
                    cell.setCellStyle(style);

                    // 1
                    cell = row.createCell(cellnum++);
                    cell.setCellValue(service.getServiceName());
                    cell.setCellStyle(style);

                    // 2
                    cell = row.createCell(cellnum++);
                    cell.setCellValue(command.getTitle());
                    cell.setCellStyle(style);

                    // 3
                    cell = row.createCell(cellnum++);
                    cell.setCellValue(command.getExec());
                    cell.setCellStyle(style);

                    // 4
                    cell = row.createCell(cellnum++);
                    cell.setCellValue("N");
                    cell.setCellStyle(style);

                    // 5
                    cell = row.createCell(cellnum++);
                    if (command.getOut().length() > 1024) {
                        cell.setCellValue(command.getOut().substring(0, 1024) + "...");
                    } else {
                        cell.setCellValue(command.getOut());
                    }
                    cell.setCellStyle(style);

                    // Error
                    if (command.isError() == true) {
                        row.getCell(0).setCellStyle(styleError);
                        row.getCell(1).setCellStyle(styleError);
                        row.getCell(2).setCellStyle(styleError);
                        row.getCell(3).setCellStyle(styleError);
                        row.getCell(4).setCellStyle(styleError);
                        row.getCell(5).setCellStyle(styleError);
                        row.getCell(4).setCellValue("Y");
                        errors++;
                    }
                }
            }
        }

        // Set Size
        sheet.setColumnWidth(0, 6000);
        sheet.setColumnWidth(1, 4000);
        sheet.setColumnWidth(2, 8000);
        sheet.setColumnWidth(3, 14000);
        sheet.setColumnWidth(4, 3000);
        sheet.setColumnWidth(5, 20000);

        // Summary
        summaryRow = summarySheet.createRow(summaryRownum++);
        summaryCellnum = 0;

        // 0
        summaryCell = summaryRow.createCell(summaryCellnum++);
        summaryCell.setCellValue(job.getJobName());
        summaryCell.setCellStyle(style);

        // Set Link
        HSSFHyperlink link = creationHelper.createHyperlink(Hyperlink.LINK_DOCUMENT);
        link.setAddress("" + job.getJobName() + "!A1");
        summaryCell.setHyperlink(link);
        summaryCell.setCellStyle(styleLink);

        // 1
        summaryCell = summaryRow.createCell(summaryCellnum++);
        summaryCell.setCellValue(jobService.getJob().getFinished());
        summaryCell.setCellStyle(style);

        // 2
        summaryCell = summaryRow.createCell(summaryCellnum++);
        summaryCell.setCellValue(errors);
        summaryCell.setCellStyle(style);

        // If errors found
        if (errors > 0) {
            summaryRow.getCell(0).setCellStyle(styleError);
            summaryRow.getCell(1).setCellStyle(styleError);
            summaryRow.getCell(2).setCellStyle(styleError);
        }
    }

    // Set Summary Size
    summarySheet.setColumnWidth(0, 6000);
    summarySheet.setColumnWidth(1, 10000);
    summarySheet.setColumnWidth(2, 4000);

    // Save
    try {
        FileOutputStream out = new FileOutputStream(new File(getFileName()));
        workbook.write(out);
        out.close();
        logger.log(Level.INFO, "{0} generated successfully..", getFileName());

        return workbook;
    } catch (FileNotFoundException ex) {
        logger.log(Level.WARNING, "Audit: {0}", ex);
    } catch (IOException ex) {
        logger.log(Level.WARNING, "Audit: {0}", ex);
    }

    return null;
}