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

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

Introduction

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

Prototype


@Override
public HSSFFont createFont() 

Source Link

Document

create a new Font and add it to the workbook's font table

Usage

From source file:org.egov.infra.web.displaytag.export.EGovExcelReadOnlyView.java

License:Open Source License

/**
 * @see org.displaytag.export.BinaryExportView#doExport(OutputStream)
 *//*from  w w w  . j  av  a2s.  c o m*/
@Override
public void doExport(final OutputStream out) throws JspException {
    try {
        final HSSFWorkbook wb = new HSSFWorkbook();
        wb.writeProtectWorkbook("egov", "egov");// To make the workbook read-only
        this.sheet = wb.createSheet("-");

        int rowNum = 0;
        int colNum = 0;

        if (this.header) {
            // Create an header row
            final HSSFRow xlsRow = this.sheet.createRow(rowNum++);

            final HSSFCellStyle headerStyle = wb.createCellStyle();
            headerStyle.setFillPattern(HSSFCellStyle.FINE_DOTS);
            headerStyle.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
            final HSSFFont bold = wb.createFont();
            bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            bold.setColor(HSSFColor.WHITE.index);
            headerStyle.setFont(bold);

            final Iterator iterator = this.model.getHeaderCellList().iterator();

            while (iterator.hasNext()) {
                final HeaderCell headerCell = (HeaderCell) iterator.next();

                String columnHeader = headerCell.getTitle();

                if (columnHeader == null) {
                    columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName());
                }

                final HSSFCell cell = xlsRow.createCell(colNum++);
                cell.setCellValue(escapeColumnValue(columnHeader));
                cell.setCellStyle(headerStyle);
            }
        }

        // get the correct iterator (full or partial list according to the exportFull field)
        final RowIterator rowIterator = this.model.getRowIterator(this.exportFull);

        // iterator on rows
        while (rowIterator.hasNext()) {
            final Row row = rowIterator.next();
            final HSSFRow xlsRow = this.sheet.createRow(rowNum++);
            colNum = 0;

            // iterator on columns
            final ColumnIterator columnIterator = row.getColumnIterator(this.model.getHeaderCellList());

            while (columnIterator.hasNext()) {
                final Column column = columnIterator.nextColumn();

                // Get the value to be displayed for the column
                final Object value = column.getValue(this.decorated);

                final HSSFCell cell = xlsRow.createCell(colNum++);

                if (value instanceof Number) {
                    final Number num = (Number) value;
                    cell.setCellValue(num.doubleValue());
                } else if (value instanceof Date) {
                    cell.setCellValue((Date) value);
                } else if (value instanceof Calendar) {
                    cell.setCellValue((Calendar) value);
                } else {
                    cell.setCellValue(escapeColumnValue(value));
                }
            }
        }

        for (short i = 0; i < colNum; i++) {
            this.sheet.autoSizeColumn(i, true);
        }
        wb.write(out);
    } catch (final Exception e) {
        throw new ExcelGenerationException(e);
    }
}

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

License:Apache License

HSSFWorkbook createAsmtStatsSheet(HSSFWorkbook workbook, List<Submission> submissions) {
    if (submissions == null || submissions.size() == 0)
        return null;

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

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

    HSSFCellStyle style = workbook.createCellStyle();
    HSSFFont font = workbook.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    style.setFont(font);/*ww  w  .j av  a2s .com*/
    // Printing header row and question text
    HSSFCell cell0 = headerRow.createCell((short) (0));
    cell0.setCellStyle(style);
    cell0.setCellValue(this.messages.getFormattedMessage("asmt_name", null));
    HSSFCell cell1 = headerRow.createCell((short) (1));
    cell1.setCellStyle(style);
    cell1.setCellValue(this.messages.getFormattedMessage("asmt_uname", null));
    HSSFCell cell2 = headerRow.createCell((short) (2));
    cell2.setCellStyle(style);
    cell2.setCellValue(this.messages.getFormattedMessage("asmt_started", null));
    HSSFCell cell3 = headerRow.createCell((short) (3));
    cell3.setCellStyle(style);
    cell3.setCellValue(this.messages.getFormattedMessage("asmt_finished", null));
    HSSFCell cell4 = headerRow.createCell((short) (4));
    cell4.setCellStyle(style);
    cell4.setCellValue(this.messages.getFormattedMessage("asmt_status", null));
    HSSFCell cell5 = headerRow.createCell((short) (5));
    cell5.setCellStyle(style);
    cell5.setCellValue(this.messages.getFormattedMessage("asmt_ascore", null));
    HSSFCell cell6 = headerRow.createCell((short) (6));
    cell6.setCellStyle(style);
    cell6.setCellValue(this.messages.getFormattedMessage("asmt_final", null) + " "
            + this.messages.getFormattedMessage("asmt_outof", null) + " "
            + submissions.get(0).getAssessment().getPoints() + ")");
    HSSFCell cell7 = headerRow.createCell((short) (7));
    cell7.setCellStyle(style);
    cell7.setCellValue(this.messages.getFormattedMessage("asmt_released", null));

    for (Submission sub : submissions) {
        HSSFRow row;

        int rowNum = sheet.getLastRowNum() + 1;
        row = sheet.createRow(rowNum);
        try {
            User user = this.userDirectoryService.getUser(sub.getUserId());
            row.createCell((short) 0).setCellValue(user.getSortName());
            row.createCell((short) 1).setCellValue(user.getDisplayId());
        } catch (UserNotDefinedException e) {
            M_log.warn("createAsmtStatsSheet: " + e.toString());
        }
        if (sub.getStartDate() != null && !sub.getIsNonSubmit())
            row.createCell((short) 2).setCellValue(formatDate(sub.getStartDate()));
        if (sub.getSubmittedDate() != null && !sub.getIsNonSubmit())
            row.createCell((short) 3).setCellValue(formatDate(sub.getSubmittedDate()));
        row.createCell((short) 4).setCellValue(getSubmissionStatus(sub));

        if (sub.getAnswersAutoScore() != null)
            row.createCell((short) 5).setCellValue(sub.getAnswersAutoScore().floatValue());
        if (sub.getTotalScore() != null)
            row.createCell((short) 6).setCellValue(sub.getTotalScore().floatValue());
        row.createCell((short) 7).setCellValue(sub.getIsReleased().booleanValue());

    }

    return workbook;
}

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

License:Apache License

/**
 * Creates Fill Blanks tab for answers Item Analysis
 *
 * @param fb_questions List of Fill Blanks questions
 * @param workbook Workbook object//from  ww w .  j  ava 2s  . c  om
 * @param assessment Assessment object
 */
void createFillBlanksTab(List<Question> fb_questions, HSSFWorkbook workbook, Assessment assessment) {
    if (fb_questions == null || fb_questions.size() == 0)
        return;

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

    boolean headerRowDone = false;
    for (Iterator it = fb_questions.iterator(); it.hasNext();) {
        Question q = (Question) it.next();
        Map<String, Integer> fbqMap = 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("FillBlanks");

            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 FillBlanksAnswerImpl) {
                FillBlanksAnswerImpl fb = (FillBlanksAnswerImpl) a;
                String[] fbAnswers = fb.getAnswers();
                for (int i = 0; i < fbAnswers.length; i++) {
                    String fbAnswer;
                    if (fb.correctFillAnswer(fbAnswers[i], i))
                        fbAnswer = "*" + fbAnswers[i] + "*";
                    else
                        fbAnswer = fbAnswers[i];
                    if (fbqMap.get(fbAnswer) != null) {
                        int count = fbqMap.get(fbAnswer).intValue();
                        count++;
                        fbqMap.put(fbAnswer, count);
                    } else
                        fbqMap.put(fbAnswer, new Integer(1));
                }
            }
        }

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

        String quest_desc = stripHtml(((FillBlanksQuestionImpl) q.getTypeSpecificQuestion()).getText());
        row.createCell((short) 0).setCellValue(quest_desc);
        int j = 1;
        if (fbqMap != null && fbqMap.size() > 0) {
            Iterator itsec = fbqMap.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 Fill Inline tab for answers Item Analysis
 *
 * @param fb_questions List of Fill Blanks questions
 * @param workbook Workbook object/*w  w  w .  ja v  a  2s  .c om*/
 * @param assessment Assessment object
 */
void createFillInlineTab(List<Question> fi_questions, HSSFWorkbook workbook, Assessment assessment) {
    if (fi_questions == null || fi_questions.size() == 0)
        return;

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

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

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

        List<ArrayList<String>> selectionLists = new ArrayList<ArrayList<String>>();
        List<String> correctAnswers = new ArrayList<String>();

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

            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));

            int i = 1;
            int k = 0;
            ((FillInlineQuestionImpl) q.getTypeSpecificQuestion()).parseSelectionLists(selectionLists,
                    correctAnswers);
            for (List<String> selList : selectionLists) {
                for (String str : selList) {
                    HSSFCell cell1 = headerRow.createCell((short) (i));
                    cell1.setCellStyle(style);
                    cell1.setCellValue(str);
                    fbqMap.put(Integer.toString(k) + str, 0);
                    i++;
                }
                k++;
            }
            headerRowDone = true;
        }

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

            if (a instanceof FillInlineAnswerImpl) {
                FillInlineAnswerImpl fb = (FillInlineAnswerImpl) a;
                String[] fbAnswers = fb.getAnswers();
                for (int i = 0; i < fbAnswers.length; i++) {
                    String fbAnswer = fbAnswers[i];
                    if (fbqMap.get(Integer.toString(i) + fbAnswer) != null) {
                        int count = fbqMap.get(Integer.toString(i) + fbAnswer).intValue();
                        count++;
                        fbqMap.put(Integer.toString(i) + fbAnswer, count);
                    }
                }
            }
        }

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

        String quest_desc = stripHtml(((FillInlineQuestionImpl) q.getTypeSpecificQuestion()).getText());
        row.createCell((short) 0).setCellValue(quest_desc);
        int j = 1;
        if (fbqMap != null && fbqMap.size() > 0) {
            int k = 0;
            for (List<String> selList : selectionLists) {
                for (String str : selList) {
                    if (str.equals(correctAnswers.get(k)))
                        row.createCell((short) j)
                                .setCellValue("*" + fbqMap.get(Integer.toString(k) + str) + "*");
                    else
                        row.createCell((short) j).setCellValue(fbqMap.get(Integer.toString(k) + str));
                    j++;
                }
                k++;
            }
        }

    }
}

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

License:Apache License

/**
 * Creates main frequency tab for Item analysis
 *
 * @param questions List of questions//from  w w w .  j a  va2s .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  ww  .  j a v a 2s .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//w  w  w.j  a  va2 s .c om
 * @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// ww  w  .j  a v  a 2  s  .  com
 * @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  ww. ja  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 . jav a2  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;
}