Example usage for org.apache.poi.hssf.usermodel HSSFCellStyle setFont

List of usage examples for org.apache.poi.hssf.usermodel HSSFCellStyle setFont

Introduction

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

Prototype

public void setFont(HSSFFont font) 

Source Link

Usage

From source file:org.etudes.mneme.impl.AttachmentServiceImpl.java

License:Apache License

/**
 * Creates main frequency tab for Item analysis
 *
 * @param questions List of questions// w  w w . j a v  a 2 s.  com
 * @param workbook Workbook object
 * @param assessment Assessment object
 * @return True if answers exist, false if not
 */
boolean createFrequencyTab(List<Question> questions, HSSFWorkbook workbook, Assessment assessment) {
    if (questions == null || questions.size() == 0)
        return false;

    String assmtId = assessment.getId();
    HSSFSheet sheet = null;
    HSSFRow row;

    boolean headerRowDone = false;
    List<Submission> submissions = this.submissionService.findAssessmentSubmissions(assessment,
            SubmissionService.FindAssessmentSubmissionsSort.sdate_a, Boolean.TRUE, null, null, null, null);

    boolean answersExist = false;
    for (Iterator it = questions.iterator(); it.hasNext();) {
        Question q = (Question) it.next();
        TypeSpecificQuestion tsq = q.getTypeSpecificQuestion();
        int count = 0;

        if (!(tsq instanceof EssayQuestionImpl) && !(tsq instanceof TaskQuestionImpl)) {
            List<Answer> allAnswers = this.submissionService.findSubmissionAnswers(assessment, q,
                    FindAssessmentSubmissionsSort.userName_a, null, null);
            if (allAnswers == null || allAnswers.size() == 0)
                continue;
            List<Answer> answers = filterOutMultiples(allAnswers, submissions);
            answersExist = true;

            if (!headerRowDone) {
                sheet = workbook.createSheet("ItemAnalysis");

                HSSFRow headerRow = sheet.createRow((short) 0);

                HSSFCellStyle style = workbook.createCellStyle();
                HSSFFont font = workbook.createFont();
                font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                style.setFont(font);
                // Printing header row
                HSSFCell cell0 = headerRow.createCell((short) (0));
                cell0.setCellStyle(style);
                cell0.setCellValue(this.messages.getFormattedMessage("item_analysis_question", null));
                HSSFCell cell9 = headerRow.createCell((short) (1));
                cell9.setCellStyle(style);
                cell9.setCellValue(this.messages.getFormattedMessage("item_analysis_title", null));
                HSSFCell cell1 = headerRow.createCell((short) (2));
                cell1.setCellStyle(style);
                cell1.setCellValue(this.messages.getFormattedMessage("item_analysis_pool", null));
                HSSFCell cell2 = headerRow.createCell((short) (3));
                cell2.setCellStyle(style);
                cell2.setCellValue(this.messages.getFormattedMessage("item_analysis_numbers", null));
                HSSFCell cell3 = headerRow.createCell((short) (4));
                cell3.setCellStyle(style);
                cell3.setCellValue(this.messages.getFormattedMessage("item_analysis_whole_group", null));
                HSSFCell cell4 = headerRow.createCell((short) (5));
                cell4.setCellStyle(style);
                cell4.setCellValue(this.messages.getFormattedMessage("item_analysis_upper_27", null));
                HSSFCell cell5 = headerRow.createCell((short) (6));
                cell5.setCellStyle(style);
                cell5.setCellValue(this.messages.getFormattedMessage("item_analysis_lower_27", null));
                HSSFCell cell6 = headerRow.createCell((short) (7));
                cell6.setCellStyle(style);
                cell6.setCellValue(this.messages.getFormattedMessage("item_analysis_diff_in", null));
                HSSFCell cell7 = headerRow.createCell((short) (8));
                cell7.setCellStyle(style);
                cell7.setCellValue(this.messages.getFormattedMessage("item_analysis_disc", null));
                HSSFCell cell8 = headerRow.createCell((short) (9));
                cell8.setCellStyle(style);
                cell8.setCellValue(this.messages.getFormattedMessage("item_analysis_freq", null));
                headerRowDone = true;
            }

            int rowNum = sheet.getLastRowNum() + 1;
            row = sheet.createRow(rowNum);
            String quest_desc = null;
            if (tsq instanceof FillBlanksQuestionImpl) {
                quest_desc = stripHtml(((FillBlanksQuestionImpl) tsq).getText());
            } else if (tsq instanceof FillInlineQuestionImpl) {
                quest_desc = stripHtml(((FillInlineQuestionImpl) tsq).getText());
            } else {
                quest_desc = stripHtml(q.getDescription());
                if (tsq instanceof OrderQuestionImpl) {
                    List<OrderQuestionImpl.OrderQuestionChoice> choiceList = ((OrderQuestionImpl) tsq)
                            .getChoicesAsAuthored();
                    String[] choiceTextArray = new String[choiceList.size()];
                    int j = 0;

                    for (OrderQuestionImpl.OrderQuestionChoice oqc : choiceList) {
                        choiceTextArray[j] = (j + 1) + "." + stripHtml(oqc.getText());
                        j++;
                    }
                    quest_desc = quest_desc + getCommaAnswers(choiceTextArray);
                }
            }
            row.createCell((short) 0).setCellValue(quest_desc);
            row.createCell((short) 1).setCellValue(q.getTitle());
            row.createCell((short) 2).setCellValue(q.getPool().getTitle());
            row.createCell((short) 3).setCellValue(answers.size());
            int numCorrects = numberOfCorrects(answers);
            double ncPc = 0.0;
            if (numCorrects > 0)
                ncPc = ((double) numberOfCorrects(answers) / answers.size()) * 100;
            row.createCell((short) 4).setCellValue(roundTwoDecimals(ncPc) + "%" + "(N=" + numCorrects + ")");
            List<ScoreUser> scoreUserList = createScoreUserList(answers);
            List<String> upperUserList = fetchUpperList(scoreUserList, 27);
            List<String> lowerUserList = fetchLowerList(scoreUserList, 27);
            int upCorrectCount = calculateCorrects(upperUserList, answers);
            double uppPc = 0.0;
            if (upCorrectCount > 0)
                uppPc = ((double) upCorrectCount / upperUserList.size()) * 100;
            row.createCell((short) 5)
                    .setCellValue(roundTwoDecimals(uppPc) + "%" + "(N=" + upCorrectCount + ")");
            int loCorrectCount = calculateCorrects(lowerUserList, answers);
            double lowPc = 0.0;
            if (loCorrectCount > 0)
                lowPc = ((double) loCorrectCount / lowerUserList.size()) * 100;
            row.createCell((short) 6)
                    .setCellValue(roundTwoDecimals(lowPc) + "%" + "(N=" + loCorrectCount + ")");
            double diffIdx = (uppPc + lowPc) / 2;
            double discrim = (uppPc - lowPc) / 100;
            row.createCell((short) 7).setCellValue(roundTwoDecimals(diffIdx));
            row.createCell((short) 8).setCellValue(roundTwoDecimals(discrim));
            for (Submission s : submissions) {
                if (s.getIsPhantom())
                    continue;
                if (!s.getIsComplete())
                    continue;

                Answer a = s.getAnswer(q);
                if (a != null) {
                    if (!a.getIsAnswered()) {
                        count++;
                    }
                }
            }
            row.createCell((short) 9).setCellValue(count);
        }
    }
    return answersExist;
}

From source file:org.etudes.mneme.impl.AttachmentServiceImpl.java

License:Apache License

/**
 * Creates Likert Scale tab for answers Item Analysis
 *
 * @param ls_questions List of Likert Scale questions
 * @param workbook Workbook object/*w  w  w  . j a  va  2 s  . c  om*/
 * @param assessment Assessment object
 */
void createLikertScaleTab(List<Question> ls_questions, HSSFWorkbook workbook, Assessment assessment) {
    if (ls_questions == null || ls_questions.size() == 0)
        return;

    String assmtId = assessment.getId();
    HSSFSheet sheet = null;
    HSSFRow row;

    boolean headerRowDone = false;
    for (Iterator it = ls_questions.iterator(); it.hasNext();) {
        Question q = (Question) it.next();
        Map<String, LikertScaleCount> lsqMap = new HashMap<String, LikertScaleCount>();

        List<LikertScaleQuestionImpl.LikertScaleQuestionChoice> choiceList = ((LikertScaleQuestionImpl) q
                .getTypeSpecificQuestion()).getChoices();
        for (Iterator chIt = choiceList.iterator(); chIt.hasNext();) {
            LikertScaleQuestionImpl.LikertScaleQuestionChoice chObj = (LikertScaleQuestionImpl.LikertScaleQuestionChoice) chIt
                    .next();
            lsqMap.put(chObj.getId(), new LikertScaleCount(chObj.getText(), 0));
        }

        List<Answer> answers = this.submissionService.findSubmissionAnswers(assessment, q,
                FindAssessmentSubmissionsSort.userName_a, null, null);
        if (answers == null || answers.size() == 0)
            return;

        if (!headerRowDone) {
            sheet = workbook.createSheet("LikertScale");

            HSSFRow headerRow = sheet.createRow((short) 0);

            HSSFCellStyle style = workbook.createCellStyle();
            HSSFFont font = workbook.createFont();
            font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            style.setFont(font);
            // Printing header row
            HSSFCell cell0 = headerRow.createCell((short) (0));
            cell0.setCellStyle(style);
            cell0.setCellValue(this.messages.getFormattedMessage("item_analysis_question", null));

            headerRowDone = true;
        }

        for (Answer answer : answers) {
            TypeSpecificAnswer a = answer.getTypeSpecificAnswer();

            if (a instanceof LikertScaleAnswerImpl) {
                LikertScaleAnswerImpl ls = (LikertScaleAnswerImpl) a;
                for (Iterator chItn = choiceList.iterator(); chItn.hasNext();) {
                    LikertScaleQuestionImpl.LikertScaleQuestionChoice lqc = (LikertScaleQuestionImpl.LikertScaleQuestionChoice) chItn
                            .next();
                    if (lqc.getId().equals(ls.getAnswer())) {
                        LikertScaleCount lscObj = (LikertScaleCount) lsqMap.get(lqc.getId());
                        lscObj.count++;
                    }
                }
            }

        }
        int rowNum = sheet.getLastRowNum() + 1;
        row = sheet.createRow(rowNum);
        String quest_desc = stripHtml(q.getDescription());
        row.createCell((short) 0).setCellValue(quest_desc);
        int i = 1;
        if (lsqMap != null && lsqMap.size() > 0) {
            Iterator itsec = lsqMap.entrySet().iterator();
            while (itsec.hasNext()) {
                Map.Entry pairs = (Map.Entry) itsec.next();
                if (pairs.getValue() != null) {
                    LikertScaleCount lscObj = (LikertScaleCount) pairs.getValue();
                    row.createCell((short) i).setCellValue("(" + lscObj.getCount() + ") " + lscObj.getText());
                    i++;
                }
            }
        }

    }
}

From source file:org.etudes.mneme.impl.AttachmentServiceImpl.java

License:Apache License

/**
 * Creates Match tab for answers Item Analysis
 *
 * @param ma_questions List of Match questions
 * @param workbook Workbook object/*from   ww  w  .jav a2  s. c  o m*/
 * @param assessment Assessment object
 */
void createMatchTab(List<Question> ma_questions, HSSFWorkbook workbook, Assessment assessment) {
    if (ma_questions == null || ma_questions.size() == 0)
        return;

    String assmtId = assessment.getId();
    HSSFSheet sheet = null;
    HSSFRow row;
    boolean headerRowDone = false;
    for (Iterator it = ma_questions.iterator(); it.hasNext();) {
        Question q = (Question) it.next();
        Map<String, Integer> maMap = new HashMap<String, Integer>();

        List<Answer> answers = this.submissionService.findSubmissionAnswers(assessment, q,
                FindAssessmentSubmissionsSort.userName_a, null, null);
        if (answers == null || answers.size() == 0)
            return;

        if (!headerRowDone) {
            sheet = workbook.createSheet("Match");
            HSSFRow headerRow = sheet.createRow((short) 0);

            HSSFCellStyle style = workbook.createCellStyle();
            HSSFFont font = workbook.createFont();
            font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            style.setFont(font);
            // Printing header row
            HSSFCell cell0 = headerRow.createCell((short) (0));
            cell0.setCellStyle(style);
            cell0.setCellValue(this.messages.getFormattedMessage("item_analysis_question", null));

            headerRowDone = true;
        }

        for (Answer answer : answers) {
            TypeSpecificAnswer a = answer.getTypeSpecificAnswer();

            if (a instanceof MatchAnswerImpl) {
                MatchAnswerImpl ma = (MatchAnswerImpl) a;
                Map matchMap = (LinkedHashMap) ma.getAnswer();
                Iterator it2 = matchMap.entrySet().iterator();
                List choiceList = ((MatchQuestionImpl) ma.getAnswerObject().getQuestion()
                        .getTypeSpecificQuestion()).getPairsForDelivery();
                while (it2.hasNext()) {
                    StringBuffer matchStrBuf = new StringBuffer();
                    Map.Entry entry = (Map.Entry) it2.next();
                    String key = (String) entry.getKey();
                    String value = (String) ((Value) entry.getValue()).getValue();
                    String matchVal = fetchName(choiceList, key, true);
                    boolean correctMatch = checkCorrectMatch(choiceList, key, value);
                    if (correctMatch)
                        matchStrBuf.append("*");
                    matchStrBuf.append(stripHtml(matchVal));
                    matchStrBuf.append("->");
                    String choiceVal = fetchName(choiceList, value, false);
                    matchStrBuf.append(stripHtml(choiceVal));
                    if (correctMatch)
                        matchStrBuf.append("*");
                    String finalStr = matchStrBuf.toString();
                    if (maMap.get(finalStr) != null) {
                        int count = maMap.get(finalStr).intValue();
                        count++;
                        maMap.put(finalStr, count);
                    } else
                        maMap.put(finalStr, new Integer(1));
                }

            }
        }

        int rowNum = sheet.getLastRowNum() + 1;
        row = sheet.createRow(rowNum);

        String quest_desc = stripHtml(q.getDescription());
        row.createCell((short) 0).setCellValue(quest_desc);
        int j = 1;
        if (maMap != null && maMap.size() > 0) {
            Iterator itsec = maMap.entrySet().iterator();
            while (itsec.hasNext()) {
                Map.Entry pairs = (Map.Entry) itsec.next();
                if (pairs.getValue() != null) {
                    row.createCell((short) j).setCellValue("(" + pairs.getValue() + ") " + pairs.getKey());
                    j++;
                }
            }
        }

    }
}

From source file:org.etudes.mneme.impl.AttachmentServiceImpl.java

License:Apache License

/**
 * Creates the Multiple Choice tab for answers Item Analysis
 *
 * @param mc_questions List of Multiple Choice questions
 * @param workbook Workbook object/*from w w  w  . j  a va  2 s  .co m*/
 * @param assessment Assessment object
 */
void createMultipleChoiceTab(List<Question> mc_questions, HSSFWorkbook workbook, Assessment assessment) {
    if (mc_questions == null || mc_questions.size() == 0)
        return;

    String assmtId = assessment.getId();
    HSSFSheet sheet = null;
    HSSFRow row;
    String[] choiceLabels = new String[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
            "0", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y" };
    int[] choiceCount = new int[25];
    boolean[] choiceCorrect = new boolean[25];

    //Determine which question has most number of choices so as to determine header column count
    int headerSize = getMaxChoices(mc_questions);

    boolean headerRowDone = false;
    //Iterate through each question
    for (Iterator it = mc_questions.iterator(); it.hasNext();) {
        Question q = (Question) it.next();

        //Fetch all submissions to the question
        List<Answer> answers = this.submissionService.findSubmissionAnswers(assessment, q,
                FindAssessmentSubmissionsSort.userName_a, null, null);
        if (answers == null || answers.size() == 0)
            return;

        //Create header row once
        if (!headerRowDone) {
            sheet = workbook.createSheet("MultipleChoice");
            HSSFRow headerRow = sheet.createRow((short) 0);

            HSSFCellStyle style = workbook.createCellStyle();
            HSSFFont font = workbook.createFont();
            font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            style.setFont(font);
            // Printing header row
            HSSFCell cell0 = headerRow.createCell((short) (0));
            cell0.setCellStyle(style);
            cell0.setCellValue(this.messages.getFormattedMessage("item_analysis_question", null));

            for (int i = 1; i <= headerSize; i++) {
                HSSFCell cell1 = headerRow.createCell((short) (i));
                cell1.setCellStyle(style);
                cell1.setCellValue(choiceLabels[i - 1]);
            }

            headerRowDone = true;
        }

        int choiceListSize = 0;
        Set<Integer> correctAnswers = ((MultipleChoiceQuestionImpl) q.getTypeSpecificQuestion())
                .getCorrectAnswerSet();

        List<MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice> choiceList = ((MultipleChoiceQuestionImpl) q
                .getTypeSpecificQuestion()).getChoicesAsAuthored();
        choiceListSize = choiceList.size();

        //Set the choiceCorrect array so we know which ones are correct choices
        //for this question
        int pos = 0;
        for (Iterator chIt = choiceList.iterator(); chIt.hasNext();) {
            MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice mq = (MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice) chIt
                    .next();
            if (correctAnswers.contains(Integer.parseInt(mq.getId()))) {
                choiceCorrect[pos] = true;
            }
            pos++;
        }

        //Iterate through each submission
        for (Answer answer : answers) {
            TypeSpecificAnswer a = answer.getTypeSpecificAnswer();

            if (a instanceof MultipleChoiceAnswerImpl) {
                MultipleChoiceAnswerImpl mc = (MultipleChoiceAnswerImpl) a;
                String[] ansArray = mc.getAnswers();

                //Iterate and compare answer and increment choiceCount
                for (int l = 0; l < ansArray.length; l++) {
                    int ansPos = 0;
                    for (Iterator chIt = choiceList.iterator(); chIt.hasNext();) {
                        MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice mq = (MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice) chIt
                                .next();
                        if (mq.getId().equals(ansArray[l])) {
                            choiceCount[ansPos]++;
                        }
                        ansPos++;
                    }
                }
            }
        }
        int rowNum = sheet.getLastRowNum() + 1;
        row = sheet.createRow(rowNum);
        String quest_desc = stripHtml(q.getDescription());
        row.createCell((short) 0).setCellValue(quest_desc);
        for (int k = 1; k <= choiceListSize; k++) {
            if (choiceCorrect[k - 1])
                row.createCell((short) k).setCellValue("*" + choiceCount[k - 1] + "*");
            else
                row.createCell((short) k).setCellValue(choiceCount[k - 1]);
        }
        for (int k = 1; k <= choiceListSize; k++) {
            choiceCount[k - 1] = 0;
            choiceCorrect[k - 1] = false;
        }
    }
}

From source file:org.etudes.mneme.impl.AttachmentServiceImpl.java

License:Apache License

/**
 * Creates the Order tab for answers Item Analysis
 *
 * @param or_questions List of Order questions
 * @param workbook Workbook object// w  w  w  .j  a  v a2  s  . c  o  m
 * @param assessment Assessment object
 */
void createOrderTab(List<Question> or_questions, HSSFWorkbook workbook, Assessment assessment) {
    if (or_questions == null || or_questions.size() == 0)
        return;

    String assmtId = assessment.getId();
    HSSFSheet sheet = null;
    HSSFRow row;
    String[] choiceLabels = new String[] { "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10." };
    int[] choiceCount = new int[10];

    //Determine which question has most number of choices so as to determine header column count
    int headerSize = getMaxChoices(or_questions);

    boolean headerRowDone = false;
    //Iterate through each question
    for (Iterator it = or_questions.iterator(); it.hasNext();) {
        Question q = (Question) it.next();

        //Fetch all submissions to the question
        List<Answer> answers = this.submissionService.findSubmissionAnswers(assessment, q,
                FindAssessmentSubmissionsSort.userName_a, null, null);
        if (answers == null || answers.size() == 0)
            return;

        //Create header row once
        if (!headerRowDone) {
            sheet = workbook.createSheet("Order");
            HSSFRow headerRow = sheet.createRow((short) 0);

            HSSFCellStyle style = workbook.createCellStyle();
            HSSFFont font = workbook.createFont();
            font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            style.setFont(font);
            // Printing header row
            HSSFCell cell0 = headerRow.createCell((short) (0));
            cell0.setCellStyle(style);
            cell0.setCellValue(this.messages.getFormattedMessage("item_analysis_question", null));

            for (int i = 1; i <= headerSize; i++) {
                HSSFCell cell1 = headerRow.createCell((short) (i));
                cell1.setCellStyle(style);
                cell1.setCellValue(choiceLabels[i - 1]);
            }

            headerRowDone = true;
        }

        int choiceListSize = 0;
        Set<Integer> correctAnswers = ((OrderQuestionImpl) q.getTypeSpecificQuestion()).getCorrectAnswerSet();

        List<OrderQuestionImpl.OrderQuestionChoice> choiceList = ((OrderQuestionImpl) q
                .getTypeSpecificQuestion()).getChoicesAsAuthored();
        choiceListSize = choiceList.size();

        //Iterate through each submission
        for (Answer answer : answers) {
            TypeSpecificAnswer a = answer.getTypeSpecificAnswer();

            if (a instanceof OrderAnswerImpl) {
                OrderAnswerImpl oa = (OrderAnswerImpl) a;
                Map<String, Value> ansMap = oa.getAnswer();

                int l = 0;
                for (OrderQuestionImpl.OrderQuestionChoice oqc : choiceList) {
                    if (ansMap.get(oqc.getId()) != null) {
                        Value value = ansMap.get(oqc.getId());
                        if (value.getValue() != null && value.getValue().equals(String.valueOf(l))) {
                            choiceCount[l]++;
                        }
                    }
                    l++;
                }

            }
        }
        int rowNum = sheet.getLastRowNum() + 1;
        row = sheet.createRow(rowNum);

        String[] choiceTextArray = new String[choiceList.size()];
        int j = 0;

        for (OrderQuestionImpl.OrderQuestionChoice oqc : choiceList) {
            choiceTextArray[j] = (j + 1) + "." + stripHtml(oqc.getText());
            j++;
        }
        String quest_desc = stripHtml(q.getDescription()) + getCommaAnswers(choiceTextArray);
        row.createCell((short) 0).setCellValue(quest_desc);
        for (int k = 1; k <= choiceListSize; k++) {
            row.createCell((short) k).setCellValue(choiceCount[k - 1]);
        }
        for (int k = 1; k <= choiceListSize; k++) {
            choiceCount[k - 1] = 0;
        }
    }
}

From source file:org.etudes.mneme.impl.AttachmentServiceImpl.java

License:Apache License

/**
 * Iterates through all question types, captures responses and creates export summary spreadsheet
 * @param workbook Workbook object/*from www .  j  ava  2  s  .c  o m*/
 * @param assessment Assessment object
 * @return Spreadsheet with Export summary
 */
HSSFSheet createResponsesSheet(HSSFWorkbook workbook, Assessment assessment) {
    boolean isSurvey;
    if (assessment.getType() == AssessmentType.survey)
        isSurvey = true;
    else
        isSurvey = false;

    Map<String, Integer> userRowMap = new HashMap();
    HSSFSheet sheet = workbook.createSheet("Submission responses");

    HSSFRow headerRow = sheet.createRow((short) 0);
    AssessmentParts part = assessment.getParts();

    List<Part> parts = part.getParts();
    if (parts == null || parts.size() == 0)
        return null;

    List<Question> questions = new ArrayList();
    for (Iterator partIt = parts.iterator(); partIt.hasNext();) {
        Part partObj = (Part) partIt.next();
        List<Question> questionsUsed = partObj.getQuestionsUsed();
        questions.addAll(questionsUsed);
    }

    HSSFCellStyle style = workbook.createCellStyle();
    HSSFFont font = workbook.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    style.setFont(font);
    // Printing header row and question text
    if (!isSurvey) {
        HSSFCell cell0 = headerRow.createCell((short) (0));
        cell0.setCellStyle(style);
        cell0.setCellValue(this.messages.getFormattedMessage("export_lastname", null));
        HSSFCell cell1 = headerRow.createCell((short) (1));
        cell1.setCellStyle(style);
        cell1.setCellValue(this.messages.getFormattedMessage("export_firstname", null));
        HSSFCell cell2 = headerRow.createCell((short) (2));
        cell2.setCellStyle(style);
        cell2.setCellValue(this.messages.getFormattedMessage("export_username", null));

        HSSFCell cell3 = headerRow.createCell((short) (3));
        cell3.setCellStyle(style);
        cell3.setCellValue(this.messages.getFormattedMessage("export_score", null));
    } else {
        HSSFCell cell0 = headerRow.createCell((short) (0));
        cell0.setCellStyle(style);
        cell0.setCellValue(this.messages.getFormattedMessage("export_user", null));
    }

    int i;
    if (isSurvey)
        i = 1;
    else
        i = 4;
    for (Iterator it = questions.iterator(); it.hasNext();) {
        Question q = (Question) it.next();
        String quest_desc = null;

        TypeSpecificQuestion tsq = q.getTypeSpecificQuestion();
        if (tsq instanceof FillBlanksQuestionImpl) {
            quest_desc = stripHtml(((FillBlanksQuestionImpl) tsq).getText());
        } else if (tsq instanceof FillInlineQuestionImpl) {
            quest_desc = stripHtml(((FillInlineQuestionImpl) tsq).getText());
        } else {
            if (tsq instanceof EssayQuestionImpl || tsq instanceof TaskQuestionImpl) {
                if (tsq instanceof EssayQuestionImpl) {
                    EssayQuestionImpl eqi = (EssayQuestionImpl) tsq;
                    if (eqi.getSubmissionType() == SubmissionType.inline)
                        quest_desc = stripHtml(q.getDescription());
                }
                if (tsq instanceof TaskQuestionImpl) {
                    TaskQuestionImpl tqi = (TaskQuestionImpl) tsq;
                    if (tqi.getSubmissionType() == SubmissionType.inline)
                        quest_desc = stripHtml(q.getDescription());
                }
            } else {
                quest_desc = stripHtml(q.getDescription());
            }
        }
        if (quest_desc != null) {
            HSSFCell cell = headerRow.createCell((short) (i++));
            cell.setCellStyle(style);
            cell.setCellValue(quest_desc);
        }
    }

    int j;
    if (isSurvey)
        j = 1;
    else
        j = 4;
    boolean answersExist = false;
    for (Iterator it = questions.iterator(); it.hasNext();) {
        Question q = (Question) it.next();
        TypeSpecificQuestion tsq = q.getTypeSpecificQuestion();
        //Only captures inline submissions for essays and tasks
        if (tsq instanceof EssayQuestionImpl || tsq instanceof TaskQuestionImpl) {
            if (tsq instanceof EssayQuestionImpl) {
                EssayQuestionImpl eqi = (EssayQuestionImpl) tsq;
                if (eqi.getSubmissionType() != SubmissionType.inline) {
                    continue;
                }
            }
            if (tsq instanceof TaskQuestionImpl) {
                TaskQuestionImpl tqi = (TaskQuestionImpl) tsq;
                if (tqi.getSubmissionType() != SubmissionType.inline) {
                    continue;
                }
            }
        }
        List<Answer> answers = this.submissionService.findSubmissionAnswers(assessment, q, Boolean.TRUE,
                FindAssessmentSubmissionsSort.userName_a, null, null);
        if (answers == null || answers.size() == 0)
            continue;
        else
            answersExist = true;
        for (Answer answer : answers) {
            HSSFRow row;
            try {
                String userId = answer.getSubmission().getUserId();
                String subId = answer.getSubmission().getId();
                if (userRowMap == null || userRowMap.size() == 0 || (userRowMap.get(userId + subId) == null)) {
                    int rowNum = sheet.getLastRowNum() + 1;
                    row = sheet.createRow(rowNum);
                    if (!isSurvey) {
                        User user = this.userDirectoryService.getUser(userId);
                        row.createCell((short) 0).setCellValue(user.getLastName());
                        row.createCell((short) 1).setCellValue(user.getFirstName());
                        row.createCell((short) 2).setCellValue(user.getDisplayId());
                        row.createCell((short) 3).setCellValue(
                                roundTwoDecimals(answer.getSubmission().getTotalScore().floatValue()));
                    } else {
                        row.createCell((short) 0)
                                .setCellValue(this.messages.getFormattedMessage("export_user", null));
                    }
                    userRowMap.put(userId + subId, new Integer(rowNum));
                } else {
                    row = sheet.getRow(userRowMap.get(userId + subId).intValue());
                }

                TypeSpecificAnswer a = answer.getTypeSpecificAnswer();
                if (a instanceof EssayAnswerImpl) {
                    EssayAnswerImpl essay = (EssayAnswerImpl) a;
                    row.createCell((short) j).setCellValue(stripHtml(essay.getAnswerData()));
                }
                if (a instanceof TrueFalseAnswerImpl) {
                    TrueFalseAnswerImpl tf = (TrueFalseAnswerImpl) a;
                    if (!isSurvey && tf.getCompletelyCorrect() != null
                            && tf.getCompletelyCorrect().booleanValue())
                        row.createCell((short) j).setCellValue("*" + tf.getAnswer() + "*");
                    else
                        row.createCell((short) j).setCellValue(tf.getAnswer());
                }
                if (a instanceof MultipleChoiceAnswerImpl) {
                    MultipleChoiceAnswerImpl mc = (MultipleChoiceAnswerImpl) a;
                    List<MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice> choiceList = ((MultipleChoiceQuestionImpl) mc
                            .getAnswerObject().getQuestion().getTypeSpecificQuestion()).getChoicesAsAuthored();
                    String[] ansArray = mc.getAnswers();
                    String[] choiceArray = new String[mc.getAnswers().length];
                    Set<Integer> correctAnswers = ((MultipleChoiceQuestionImpl) mc.getAnswerObject()
                            .getQuestion().getTypeSpecificQuestion()).getCorrectAnswerSet();

                    int l = 0;
                    for (Iterator chIt = choiceList.iterator(); chIt.hasNext();) {
                        MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice mq = (MultipleChoiceQuestionImpl.MultipleChoiceQuestionChoice) chIt
                                .next();

                        if (Arrays.asList(ansArray).contains(mq.getId())) {
                            if (!isSurvey && correctAnswers.contains(Integer.parseInt(mq.getId()))) {
                                choiceArray[l] = "*" + stripHtml(mq.getText().trim()) + "*";
                            } else {
                                choiceArray[l] = stripHtml(mq.getText().trim());
                            }
                            l++;
                        }
                    }

                    row.createCell((short) j).setCellValue(getCommaAnswers(choiceArray));
                }
                if (a instanceof OrderAnswerImpl) {
                    OrderAnswerImpl oa = (OrderAnswerImpl) a;
                    List<OrderQuestionImpl.OrderQuestionChoice> choiceList = ((OrderQuestionImpl) oa
                            .getAnswerObject().getQuestion().getTypeSpecificQuestion()).getChoicesAsAuthored();
                    Map<String, Value> ansMap = oa.getAnswer();
                    String[] choiceArray = new String[ansMap.size()];
                    int l = 0;
                    for (Map.Entry entry : ansMap.entrySet()) {
                        String entryId = (String) entry.getKey();
                        // Value value = ansMap.get(oqc.getId());
                        if (!isSurvey && entry.getValue() != null
                                && ((Value) entry.getValue()).getValue() != null
                                && ((Value) entry.getValue()).getValue().equals(
                                        entryId)/*((OrderQuestionImpl.OrderQuestionChoice) choiceList.get(l)).getId().equals(entryId)*/) {
                            choiceArray[l] = "*" + stripHtml(getChoiceText(choiceList, entryId).trim()) + "*";
                        } else {
                            if (((Value) entry.getValue()).getValue() == null) {
                                choiceArray[l] = "Select";
                            } else {
                                choiceArray[l] = stripHtml(getChoiceText(choiceList, entryId).trim());
                            }
                        }

                        l++;
                    }

                    row.createCell((short) j).setCellValue(getCommaAnswers(choiceArray));
                }
                if (a instanceof FillBlanksAnswerImpl) {
                    FillBlanksAnswerImpl fb = (FillBlanksAnswerImpl) a;
                    row.createCell((short) j)
                            .setCellValue(stripHtml(getCommaAnswers(checkCorrectFill(fb, isSurvey))));
                }
                if (a instanceof FillInlineAnswerImpl) {
                    FillInlineAnswerImpl fi = (FillInlineAnswerImpl) a;
                    row.createCell((short) j)
                            .setCellValue(stripHtml(getCommaAnswers(checkCorrectFillInline(fi, isSurvey))));
                }
                if (a instanceof LikertScaleAnswerImpl) {
                    LikertScaleAnswerImpl ls = (LikertScaleAnswerImpl) a;
                    LikertScaleQuestionImpl lsq = (LikertScaleQuestionImpl) ls.getAnswerObject().getQuestion()
                            .getTypeSpecificQuestion();
                    List<LikertScaleQuestionImpl.LikertScaleQuestionChoice> choiceList = lsq.getChoices();
                    for (Iterator chIt = choiceList.iterator(); chIt.hasNext();) {
                        LikertScaleQuestionImpl.LikertScaleQuestionChoice lqc = (LikertScaleQuestionImpl.LikertScaleQuestionChoice) chIt
                                .next();
                        if (lqc.getId().equals(ls.getAnswer())) {
                            row.createCell((short) j).setCellValue(stripHtml(lqc.getText()));
                            break;
                        }
                    }
                }
                if (a instanceof MatchAnswerImpl) {
                    MatchAnswerImpl ma = (MatchAnswerImpl) a;
                    Map matchMap = (LinkedHashMap) ma.getAnswer();
                    Iterator it2 = matchMap.entrySet().iterator();
                    StringBuffer matchStrBuf = new StringBuffer();

                    List choiceList = ((MatchQuestionImpl) ma.getAnswerObject().getQuestion()
                            .getTypeSpecificQuestion()).getPairsForDelivery();
                    while (it2.hasNext()) {
                        Map.Entry entry = (Map.Entry) it2.next();
                        String key = (String) entry.getKey();
                        String value = (String) ((Value) entry.getValue()).getValue();
                        String matchVal = fetchName(choiceList, key, true);
                        boolean correctMatch = checkCorrectMatch(choiceList, key, value);
                        if (!isSurvey && correctMatch)
                            matchStrBuf.append("*");
                        matchStrBuf.append(stripHtml(matchVal.trim()));
                        matchStrBuf.append("->");
                        String choiceVal = fetchName(choiceList, value, false);
                        if (choiceVal == null)
                            matchStrBuf.append(this.messages.getFormattedMessage("nosel_made", null));
                        else
                            matchStrBuf.append(stripHtml(choiceVal.trim()));

                        if (!isSurvey && correctMatch)
                            matchStrBuf.append("*");
                        matchStrBuf.append(", ");
                    }
                    if (matchStrBuf.length() > 0 && matchStrBuf.charAt(matchStrBuf.length() - 2) == ',') {
                        String matchStrBufTrim = matchStrBuf.substring(0, matchStrBuf.length() - 2);
                        row.createCell((short) j).setCellValue(stripHtml(matchStrBufTrim));
                    }
                }
                if (a instanceof TaskAnswerImpl) {
                    TaskAnswerImpl ta = (TaskAnswerImpl) a;
                    row.createCell((short) j).setCellValue(stripHtml(ta.getAnswerData()));
                }
            } catch (UserNotDefinedException e) {
                M_log.warn("createResponsesSheet: " + e.toString());
            }
        }
        j = j + 1;
    }
    if (!answersExist)
        return null;
    return sheet;
}

From source file:org.etudes.mneme.impl.AttachmentServiceImpl.java

License:Apache License

/**
 * Creates True False tab for answers Item Analysis
 *
 * @param tf_questions List of True False questions
 * @param workbook Workbook object//  w  ww .  j  a  v  a2  s.co m
 * @param assessment Assessment object
 */
void createTrueFalseTab(List<Question> tf_questions, HSSFWorkbook workbook, Assessment assessment) {
    if (tf_questions == null || tf_questions.size() == 0)
        return;

    String assmtId = assessment.getId();
    HSSFSheet sheet = null;
    HSSFRow row;

    boolean headerRowDone = false;
    for (Iterator it = tf_questions.iterator(); it.hasNext();) {
        Question q = (Question) it.next();

        List<Answer> answers = this.submissionService.findSubmissionAnswers(assessment, q,
                FindAssessmentSubmissionsSort.userName_a, null, null);
        if (answers == null || answers.size() == 0)
            return;

        if (!headerRowDone) {
            sheet = workbook.createSheet("TrueFalse");

            HSSFRow headerRow = sheet.createRow((short) 0);

            HSSFCellStyle style = workbook.createCellStyle();
            HSSFFont font = workbook.createFont();
            font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            style.setFont(font);
            // Printing header row
            HSSFCell cell0 = headerRow.createCell((short) (0));
            cell0.setCellStyle(style);
            cell0.setCellValue(this.messages.getFormattedMessage("item_analysis_question", null));
            HSSFCell cell1 = headerRow.createCell((short) (1));
            cell1.setCellStyle(style);
            cell1.setCellValue(this.messages.getFormattedMessage("true-header", null));
            HSSFCell cell2 = headerRow.createCell((short) (2));
            cell2.setCellStyle(style);
            cell2.setCellValue(this.messages.getFormattedMessage("false-header", null));

            headerRowDone = true;
        }

        int trueCount = 0, falseCount = 0;

        for (Answer answer : answers) {
            TypeSpecificAnswer a = answer.getTypeSpecificAnswer();
            if (a instanceof TrueFalseAnswerImpl) {
                TrueFalseAnswerImpl tf = (TrueFalseAnswerImpl) a;
                if (tf.getAnswer().equals("true"))
                    trueCount++;
                if (tf.getAnswer().equals("false"))
                    falseCount++;
            }
        }
        int rowNum = sheet.getLastRowNum() + 1;
        row = sheet.createRow(rowNum);
        String quest_desc = stripHtml(q.getDescription());
        row.createCell((short) 0).setCellValue(quest_desc);
        if (((TrueFalseQuestionImpl) q.getTypeSpecificQuestion()).getCorrectAnswer().equals("true"))
            row.createCell((short) 1).setCellValue("*" + trueCount + "*");
        else
            row.createCell((short) 1).setCellValue(trueCount);
        if (((TrueFalseQuestionImpl) q.getTypeSpecificQuestion()).getCorrectAnswer().equals("false"))
            row.createCell((short) 2).setCellValue("*" + falseCount + "*");
        else
            row.createCell((short) 2).setCellValue(falseCount);

    }
}

From source file:org.executequery.gui.importexport.DefaultExcelWorkbookBuilder.java

License:Open Source License

public void addRowHeader(List<String> values) {

    if (currentRow > 0) {

        currentRow++;//from w ww  .  j  av a2s.  co m
    }

    HSSFFont font = createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

    HSSFCellStyle style = createStyle();
    style.setFont(font);

    fillRow(values, createRow(currentRow), style);
}

From source file:org.exoplatform.addon.pulse.service.ws.RestActivitiesStatistic.java

License:Open Source License

private HSSFWorkbook buildExportDataForExcel(String maxColumn, String filter, Date fromDate,
        boolean isExportNewUsersData, boolean isExportLoginCountData, boolean isExportForumActiveUsersData,
        boolean isExportNewForumPostsData, boolean isExportPlfDownloadsData, boolean isExportUserConnectionData,
        boolean isExportSocialPostData, boolean isExportEmailNotificationData) throws Exception {
    ChartData data = buildExportData(maxColumn, filter, fromDate, isExportPlfDownloadsData);
    String fileName = "export_" + maxColumn + "_" + filter + "_from_" + partString(fromDate, "yyyy.MM.dd")
            + ".xls";

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

    // index from 0,0... cell A1 is cell(0,0)

    HSSFCellStyle headerCellStyle = workbook.createCellStyle();
    HSSFFont hSSFFont = workbook.createFont();
    hSSFFont.setFontName(HSSFFont.FONT_ARIAL);
    hSSFFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    hSSFFont.setColor(HSSFColor.BLACK.index);
    headerCellStyle.setFont(hSSFFont);

    HSSFRow headerRow = worksheet.createRow((short) 0);
    HSSFCell cellA1 = headerRow.createCell(0);
    cellA1.setCellValue("Statistics");
    cellA1.setCellStyle(headerCellStyle);

    for (int i = 0; i < data.getListTitle().size(); i++) {
        HSSFCell cell = headerRow.createCell(i + 1);
        cell.setCellValue(data.getListTitle().get(i));
        cell.setCellStyle(headerCellStyle);
    }//from   w ww. j  a  v a  2 s  .  co m

    HSSFCell totalCell = headerRow.createCell(data.getListTitle().size() + 1);
    totalCell.setCellValue("Total");
    totalCell.setCellStyle(headerCellStyle);

    int rowIndex = 1;
    if (isExportNewUsersData) {
        HSSFRow metricRow = worksheet.createRow(rowIndex);
        HSSFCell metricCell = metricRow.createCell(0);
        metricCell.setCellValue("New Users Registration");
        Long total = 0L;
        for (int i = 0; i < data.getNewUsersData().size(); i++) {
            total += data.getNewUsersData().get(i);
            HSSFCell cell = metricRow.createCell(i + 1);
            cell.setCellValue(data.getNewUsersData().get(i));
        }
        HSSFCell metricTotalCell = metricRow.createCell(data.getNewUsersData().size() + 1);
        metricTotalCell.setCellValue(total);

        rowIndex++;
    }

    if (isExportLoginCountData) {
        HSSFRow metricRow = worksheet.createRow(rowIndex);
        HSSFCell metricCell = metricRow.createCell(0);
        metricCell.setCellValue("Nb Unique Login");
        Long total = 0L;
        for (int i = 0; i < data.getLoginCountData().size(); i++) {
            total += data.getLoginCountData().get(i);
            HSSFCell cell = metricRow.createCell(i + 1);
            cell.setCellValue(data.getLoginCountData().get(i));
        }
        HSSFCell metricTotalCell = metricRow.createCell(data.getLoginCountData().size() + 1);
        metricTotalCell.setCellValue(total);

        rowIndex++;
    }

    if (isExportForumActiveUsersData) {
        HSSFRow metricRow = worksheet.createRow(rowIndex);
        HSSFCell metricCell = metricRow.createCell(0);
        metricCell.setCellValue("Forum Active Users Average");
        Long total = 0L;
        int itemHasData = 0;
        for (int i = 0; i < data.getForumActiveUsersData().size(); i++) {
            total += data.getForumActiveUsersData().get(i);
            if (data.getForumActiveUsersData().get(i) > 0)
                itemHasData++;
            HSSFCell cell = metricRow.createCell(i + 1);
            cell.setCellValue(data.getForumActiveUsersData().get(i));
        }
        HSSFCell metricTotalCell = metricRow.createCell(data.getForumActiveUsersData().size() + 1);
        Long average = itemHasData > 0 ? total / itemHasData : 0L;
        metricTotalCell.setCellValue(average);

        rowIndex++;
    }

    if (isExportNewForumPostsData) {
        HSSFRow metricRow = worksheet.createRow(rowIndex);
        HSSFCell metricCell = metricRow.createCell(0);
        metricCell.setCellValue("New Forum Posts");
        Long total = 0L;
        for (int i = 0; i < data.getNewForumPostsData().size(); i++) {
            total += data.getNewForumPostsData().get(i);
            HSSFCell cell = metricRow.createCell(i + 1);
            cell.setCellValue(data.getNewForumPostsData().get(i));
        }
        HSSFCell metricTotalCell = metricRow.createCell(data.getNewForumPostsData().size() + 1);
        metricTotalCell.setCellValue(total);

        rowIndex++;
    }

    if (isExportUserConnectionData) {
        HSSFRow metricRow = worksheet.createRow(rowIndex);
        HSSFCell metricCell = metricRow.createCell(0);
        metricCell.setCellValue("New User connections");
        Long total = 0L;
        for (int i = 0; i < data.getUserConnectionData().size(); i++) {
            total += data.getUserConnectionData().get(i);
            HSSFCell cell = metricRow.createCell(i + 1);
            cell.setCellValue(data.getUserConnectionData().get(i));
        }
        HSSFCell metricTotalCell = metricRow.createCell(data.getUserConnectionData().size() + 1);
        metricTotalCell.setCellValue(total);

        rowIndex++;
    }

    if (isExportSocialPostData) {
        HSSFRow metricRow = worksheet.createRow(rowIndex);
        HSSFCell metricCell = metricRow.createCell(0);
        metricCell.setCellValue("New posts in activities stream");
        Long total = 0L;
        for (int i = 0; i < data.getSocialPostData().size(); i++) {
            total += data.getSocialPostData().get(i);
            HSSFCell cell = metricRow.createCell(i + 1);
            cell.setCellValue(data.getSocialPostData().get(i));
        }
        HSSFCell metricTotalCell = metricRow.createCell(data.getSocialPostData().size() + 1);
        metricTotalCell.setCellValue(total);

        rowIndex++;
    }

    if (isExportEmailNotificationData) {
        HSSFRow metricRow = worksheet.createRow(rowIndex);
        HSSFCell metricCell = metricRow.createCell(0);
        metricCell.setCellValue("Number of notification emails sent");
        Long total = 0L;
        for (int i = 0; i < data.getEmailNotificationData().size(); i++) {
            total += data.getEmailNotificationData().get(i);
            HSSFCell cell = metricRow.createCell(i + 1);
            cell.setCellValue(data.getEmailNotificationData().get(i));
        }
        HSSFCell metricTotalCell = metricRow.createCell(data.getEmailNotificationData().size() + 1);
        metricTotalCell.setCellValue(total);

        rowIndex++;
    }

    if (isExportPlfDownloadsData) {
        HSSFRow metricRow = worksheet.createRow(rowIndex);
        HSSFCell metricCell = metricRow.createCell(0);
        metricCell.setCellValue("PLF Downloads");
        Long total = 0L;
        for (int i = 0; i < data.getPlfDownloadsData().size(); i++) {
            total += data.getPlfDownloadsData().get(i);
            HSSFCell cell = metricRow.createCell(i + 1);
            cell.setCellValue(data.getPlfDownloadsData().get(i));
        }
        HSSFCell metricTotalCell = metricRow.createCell(data.getPlfDownloadsData().size() + 1);
        metricTotalCell.setCellValue(total);

        rowIndex++;
    }
    return workbook;
}

From source file:org.extremecomponents.table.view.ExtendXlsView.java

License:Apache License

private Map initStyles(HSSFWorkbook wb, short fontHeight) {
    Map result = new HashMap();
    HSSFCellStyle titleStyle = wb.createCellStyle();
    HSSFCellStyle textStyle = wb.createCellStyle();
    HSSFCellStyle boldStyle = wb.createCellStyle();
    HSSFCellStyle numericStyle = wb.createCellStyle();
    HSSFCellStyle numericStyleBold = wb.createCellStyle();
    HSSFCellStyle moneyStyle = wb.createCellStyle();
    HSSFCellStyle moneyStyleBold = wb.createCellStyle();
    HSSFCellStyle percentStyle = wb.createCellStyle();
    HSSFCellStyle percentStyleBold = wb.createCellStyle();

    result.put("titleStyle", titleStyle);
    result.put("textStyle", textStyle);
    result.put("boldStyle", boldStyle);
    result.put("numericStyle", numericStyle);
    result.put("numericStyleBold", numericStyleBold);
    result.put("moneyStyle", moneyStyle);
    result.put("moneyStyleBold", moneyStyleBold);
    result.put("percentStyle", percentStyle);
    result.put("percentStyleBold", percentStyleBold);

    HSSFDataFormat format = wb.createDataFormat();

    // Global fonts
    HSSFFont font = wb.createFont();//from   w w w  .  j a  v  a2s .c o  m
    font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
    font.setColor(HSSFColor.BLACK.index);
    font.setFontName(HSSFFont.FONT_ARIAL);
    font.setFontHeightInPoints(fontHeight);

    HSSFFont fontBold = wb.createFont();
    fontBold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    fontBold.setColor(HSSFColor.BLACK.index);
    fontBold.setFontName(HSSFFont.FONT_ARIAL);
    fontBold.setFontHeightInPoints(fontHeight);

    // Money Style
    moneyStyle.setFont(font);
    moneyStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    moneyStyle.setDataFormat(format.getFormat(moneyFormat));

    // Money Style Bold
    moneyStyleBold.setFont(fontBold);
    moneyStyleBold.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    moneyStyleBold.setDataFormat(format.getFormat(moneyFormat));

    // Percent Style
    percentStyle.setFont(font);
    percentStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    percentStyle.setDataFormat(format.getFormat(percentFormat));

    // Percent Style Bold
    percentStyleBold.setFont(fontBold);
    percentStyleBold.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    percentStyleBold.setDataFormat(format.getFormat(percentFormat));

    // Standard Numeric Style
    numericStyle.setFont(font);
    numericStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);

    // Standard Numeric Style Bold
    numericStyleBold.setFont(fontBold);
    numericStyleBold.setAlignment(HSSFCellStyle.ALIGN_RIGHT);

    // Title Style
    titleStyle.setFont(font);
    titleStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    titleStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    titleStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    titleStyle.setBottomBorderColor(HSSFColor.BLACK.index);
    titleStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    titleStyle.setLeftBorderColor(HSSFColor.BLACK.index);
    titleStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
    titleStyle.setRightBorderColor(HSSFColor.BLACK.index);
    titleStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
    titleStyle.setTopBorderColor(HSSFColor.BLACK.index);
    titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    titleStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

    // Standard Text Style
    textStyle.setFont(font);
    textStyle.setWrapText(true);

    // Standard Text Style
    boldStyle.setFont(fontBold);
    boldStyle.setWrapText(true);

    return result;
}