Example usage for org.apache.poi.ss.usermodel CreationHelper createHyperlink

List of usage examples for org.apache.poi.ss.usermodel CreationHelper createHyperlink

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel CreationHelper createHyperlink.

Prototype

Hyperlink createHyperlink(HyperlinkType type);

Source Link

Document

Creates a new Hyperlink, of the given type

Usage

From source file:org.bbreak.excella.core.util.PoiUtil.java

License:Open Source License

/**
 * ???/*from   ww w . j  a  v  a  2s .c  om*/
 * 
 * @param cell 
 * @param type 
 * @param address ?
 * @see org.apache.poi.common.usermodel.Hyperlink
 */
public static void setHyperlink(Cell cell, HyperlinkType hyperlinkType, String address) {

    Workbook wb = cell.getRow().getSheet().getWorkbook();

    CreationHelper createHelper = wb.getCreationHelper();

    Hyperlink link = createHelper.createHyperlink(hyperlinkType);
    if (link instanceof HSSFHyperlink) {
        ((HSSFHyperlink) link).setTextMark(address);
    } else if (link instanceof XSSFHyperlink) {
        ((XSSFHyperlink) link).setAddress(address);
    }

    cell.setHyperlink(link);
}

From source file:org.cerberus.service.export.ExportServiceFactory.java

License:Open Source License

private int createRow(String test, HashMap<String, List<TestCaseExecution>> executionsPerTestCase, Sheet sheet,
        int currentIndex, List<String> mapCountries) {

    int lastRow = currentIndex + executionsPerTestCase.size();

    int current = currentIndex;

    TreeMap<String, List<TestCaseExecution>> sortedKeys = new TreeMap<String, List<TestCaseExecution>>(
            executionsPerTestCase);//from w  ww . j a  v  a2s.com
    CellStyle wrapStyle = sheet.getColumnStyle(0); //Create new style
    wrapStyle.setWrapText(true); //Set wordwrap

    for (String testCaseKey : sortedKeys.keySet()) {
        List<String> browserEnvironment = new LinkedList<String>();
        String application;
        String description;
        Row r = sheet.createRow(current);
        List<TestCaseExecution> executionList = executionsPerTestCase.get(testCaseKey);
        Cell testCell = r.createCell(0);
        testCell.setCellValue(test);
        testCell.setCellStyle(wrapStyle);
        r.createCell(1).setCellValue(testCaseKey);

        //gets the first object to retrieve the application - at least exists one test case execution
        if (executionList.isEmpty()) {
            application = "N/D";
            description = "N/D";
        } else {
            application = executionList.get(0).getApplication();
            description = executionList.get(0).getTestCaseObj().getBehaviorOrValueExpected();
        }
        //Sets the application and description
        r.createCell(2).setCellValue(application);
        r.createCell(3).setCellValue(description);

        int rowStartedTestCaseInfo = current;

        for (TestCaseExecution exec : executionList) {
            if (browserEnvironment.isEmpty()) {
                browserEnvironment.add(exec.getEnvironment() + "_" + exec.getBrowser());
                r.createCell(4).setCellValue(exec.getEnvironment());
                r.createCell(5).setCellValue(exec.getBrowser());
            } else {
                int index = browserEnvironment.indexOf(exec.getEnvironment() + "_" + exec.getBrowser());

                //Does not exist any information about browser and environment
                if (browserEnvironment.indexOf(exec.getEnvironment() + "_" + exec.getBrowser()) == -1) {
                    //need to add another row with the same characteristics
                    r = sheet.createRow(++current);
                    r.createCell(0).setCellValue(test);
                    r.createCell(1).setCellValue(testCaseKey);
                    r.createCell(2).setCellValue(application);
                    r.createCell(3).setCellValue(description);
                    r.createCell(4).setCellValue(exec.getEnvironment());
                    r.createCell(5).setCellValue(exec.getBrowser());

                    browserEnvironment.add(exec.getEnvironment() + "_" + exec.getBrowser());
                } else {
                    //there is information about the browser and environment
                    Row rowExisting = sheet.getRow(rowStartedTestCaseInfo + index);
                    r = rowExisting;
                }

            }

            //TODO:FN tirar daqui estes valores
            int indexOfCountry = mapCountries.indexOf(exec.getCountry()) + 6;
            Cell executionResult = r.createCell(indexOfCountry);
            executionResult.setCellValue(exec.getControlStatus());
            //Create hyperling
            CreationHelper createHelper = sheet.getWorkbook().getCreationHelper();
            CellStyle hlinkstyle = sheet.getWorkbook().createCellStyle();
            Font hlinkfont = sheet.getWorkbook().createFont();
            hlinkfont.setUnderline(XSSFFont.U_SINGLE);
            hlinkfont.setColor(HSSFColor.BLUE.index);
            hlinkstyle.setFont(hlinkfont);

            Hyperlink link = (Hyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
            link.setAddress("http://www.tutorialspoint.com/");
            executionResult.setHyperlink((Hyperlink) link);
            executionResult.setCellStyle(hlinkstyle);

        }
        current++;

    }

    /*r.createCell(1).setCellValue("");
     r.createCell(2).setCellValue("");
     r.createCell(3).setCellValue("");
     r.createCell(4).setCellValue("");
     r.createCell(5).setCellValue("");
     */
    //        for(TestCaseWithExecution exec : execution){
    //            
    //            //r.createCell(2).setCellValue(exec.getDescription());
    //            //r.createCell(3).setCellValue(exec.getApplication());
    //            //r.createCell(4).setCellValue(exec.getEnvironment());
    //            //r.createCell(5).setCellValue(exec.getBrowser());
    //            int indexOfCountry = mapCountries.indexOf(exec.getCountry()) + 6;
    //            r.createCell(indexOfCountry).setCellValue(exec.getControlStatus());
    //            //current++;
    //        }
    //puts the test name in the first column
    /*r = sheet.getRow(currentIndex);
     r.getCell(0).setCellValue(test);
     */
    /*CellRangeAddress range = new CellRangeAddress(currentIndex, lastRow, 0, 0);
     sheet.addMergedRegion(range);*/
    return lastRow;
}

From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.BudgetByMOGSummaryXLS.java

License:Open Source License

/**
 * This method is used to add an institution being a project leader
 * /*from  w w w  .ja  v  a 2 s.c  o  m*/
 * @param projectLeadingInstitutions is the list of institutions to be added
 * @param projectList is the list with the projects related to each institution
 */
private void addContent(List<Map<String, Object>> informationListMapPOWB, Sheet sheet, int indexSheet,
        XSSFWorkbook workbook) {

    CreationHelper createHelper = workbook.getCreationHelper();
    XSSFHyperlink link;
    Map<String, Object> mapObject;
    StringBuilder stringBuilder;
    String valueOne, valueTwo;
    int projectID;
    // Iterating all the projects

    if (indexSheet == 0) {
        for (int a = 0; a < informationListMapPOWB.size(); a++) {
            mapObject = informationListMapPOWB.get(a);

            // Iterating all the partners

            // Outcome
            stringBuilder = new StringBuilder();

            valueOne = (String) mapObject.get("outcome_flagship");
            valueTwo = (String) mapObject.get("outcome_description");

            if (valueOne != null && valueTwo != null) {
                stringBuilder.append(valueOne);
                stringBuilder.append(" - ");
                stringBuilder.append(valueTwo);
            } else {
                stringBuilder.append("");
            }

            xls.writeString(sheet, stringBuilder.toString());
            xls.nextColumn();

            // MOG description
            stringBuilder = new StringBuilder();

            valueOne = (String) mapObject.get("mog_flagship");
            valueTwo = (String) mapObject.get("mog_description");

            if (valueOne != null && valueTwo != null) {
                stringBuilder.append(valueOne);
                stringBuilder.append(" - ");
                stringBuilder.append(valueTwo);
            } else {
                stringBuilder.append("");
            }

            xls.writeString(sheet, stringBuilder.toString());
            xls.nextColumn();

            // budget_W1_W2
            xls.writeBudget(sheet, (double) mapObject.get("budget_W1_W2"));
            xls.nextColumn();

            // gender_W1_W2
            xls.writeBudget(sheet, (double) mapObject.get("gender_W1_W2"));
            xls.nextColumn();

            // budget_W3_Bilateral
            xls.writeBudget(sheet, (double) mapObject.get("budget_W3_Bilateral"));
            xls.nextColumn();

            // gender_W3_Bilateral
            xls.writeBudget(sheet, (double) mapObject.get("gender_W3_Bilateral"));

            xls.nextRow();

        }
    } else if (indexSheet == 1) {
        for (int a = 0; a < informationListMapPOWB.size(); a++) {
            mapObject = informationListMapPOWB.get(a);

            // Iterating all the partners

            projectID = (int) mapObject.get("project_id");
            link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
            link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectID);

            // Project id
            xls.writeHyperlink(sheet, "P" + String.valueOf(projectID), link);
            xls.nextColumn();

            // Title
            xls.writeString(sheet, (String) mapObject.get("project_title"));
            xls.nextColumn();

            // project Type
            xls.writeString(sheet, ((String) mapObject.get("project_type")).replace("_", " "));
            xls.nextColumn();

            // MOG description
            stringBuilder = new StringBuilder();
            valueOne = (String) mapObject.get("flagship");
            valueTwo = (String) mapObject.get("mog_description");

            if (valueOne != null && valueTwo != null) {
                stringBuilder.append(valueOne);
                stringBuilder.append(" - ");
                stringBuilder.append(valueTwo);
            } else {
                stringBuilder.append("");
            }

            xls.writeString(sheet, stringBuilder.toString());
            xls.nextColumn();

            // Annual description
            xls.writeString(sheet, (String) mapObject.get("anual_contribution"));
            xls.nextColumn();

            // Gender description
            xls.writeString(sheet, (String) mapObject.get("gender_contribution"));
            xls.nextColumn();

            // budget_W1_W2
            xls.writeBudget(sheet, (double) mapObject.get("budget_W1_W2"));
            xls.nextColumn();

            // gender_W1_W2
            xls.writeBudget(sheet, (double) mapObject.get("gender_W1_W2"));
            xls.nextColumn();

            // budget_W3_Bilateral
            xls.writeBudget(sheet, (double) mapObject.get("budget_W3_Bilateral"));
            xls.nextColumn();

            // gender_W3_Bilateral
            xls.writeBudget(sheet, (double) mapObject.get("gender_W3_Bilateral"));
            xls.nextColumn();

            xls.nextRow();
        }
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.BudgetPerPartnersSummaryXLS.java

License:Open Source License

/**
 * This method is used to add an institution being a project leader
 * /*from  w ww  . jav  a 2 s .  c  om*/
 * @param projectLeadingInstitutions is the list of institutions to be added
 * @param projectList is the list with the projects related to each institution
 */
private void addContent(List<Map<String, Object>> informationBudgetByPartnerList, Sheet sheet) {

    CreationHelper createHelper = sheet.getWorkbook().getCreationHelper();
    XSSFHyperlink link;
    Map<String, Object> mapObject;
    int projectID;
    // Iterating all the projects

    for (int a = 0; a < informationBudgetByPartnerList.size(); a++) {
        mapObject = informationBudgetByPartnerList.get(a);

        // Iterating all the partners

        projectID = (int) mapObject.get("project_id");
        link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
        link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectID);

        // Project id
        xls.writeHyperlink(sheet, "P" + String.valueOf(projectID), link);
        xls.nextColumn();

        // Title
        xls.writeString(sheet, (String) mapObject.get("project_title"));
        xls.nextColumn();

        // Partner
        xls.writeString(sheet, (String) mapObject.get("partner"));
        xls.nextColumn();

        // budget_W1_W2
        xls.writeBudget(sheet, (double) mapObject.get("budget_W1_W2"));
        xls.nextColumn();

        // gender_W1_W2
        xls.writeBudget(sheet, (double) mapObject.get("gender_W1_W2"));
        xls.nextColumn();

        // budget_W3_Bilateral
        xls.writeBudget(sheet, (double) mapObject.get("budget_W3_Bilateral"));
        xls.nextColumn();

        // gender_W3_Bilateral
        xls.writeBudget(sheet, (double) mapObject.get("gender_W3_Bilateral"));
        xls.nextColumn();

        xls.nextRow();

    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.DeliverablePlanningSummaryXLS.java

License:Open Source License

/**
 * This method is used to add an institution being a project leader
 * /*from w ww. j  ava 2  s. c  om*/
 * @param projectLeadingInstitutions is the list of institutions to be added
 * @param projectList is the list with the projects related to each institution
 */

private void addContent(List<Map<String, Object>> deliverableList, XSSFWorkbook workbook) {

    XSSFHyperlink link;
    Sheet sheet = workbook.getSheetAt(0);
    CreationHelper createHelper = workbook.getCreationHelper();
    Map<String, Object> deliverableMap;
    int projectID;

    // Main Type
    StringBuilder stringBuilder;

    // Iterating all the projects
    for (int a = 0; a < deliverableList.size(); a++) {
        deliverableMap = deliverableList.get(a);

        projectID = (int) deliverableMap.get("project_id");
        link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
        link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectID);

        // Project id
        xls.writeHyperlink(sheet, "P" + String.valueOf(projectID), link);
        xls.nextColumn();

        // Title
        xls.writeString(sheet, (String) deliverableMap.get("project_title"));
        xls.nextColumn();

        // Flashig
        xls.writeString(sheet, (String) deliverableMap.get("flagships"));
        xls.nextColumn();

        // Region
        xls.writeString(sheet, (String) deliverableMap.get("regions"));
        xls.nextColumn();

        // Title
        xls.writeString(sheet, this.messageReturn((String) deliverableMap.get("deliverable_title")));
        xls.nextColumn();

        // MOG
        xls.writeString(sheet, this.messageReturn((String) deliverableMap.get("mog")));
        xls.nextColumn();

        // Year
        xls.writeInteger(sheet, (int) deliverableMap.get("year"));
        xls.nextColumn();

        // Main type
        xls.writeString(sheet, this.messageReturn((String) deliverableMap.get("deliverable_type")));
        xls.nextColumn();

        // Sub Type
        int deliverableTypeId = (int) deliverableMap.get("deliverable_type_id");
        stringBuilder = new StringBuilder();
        if (deliverableTypeId == 38) {
            stringBuilder.append("Other: (");
            stringBuilder.append(this.messageReturn((String) deliverableMap.get("other_type")));
            stringBuilder.append(")");
        } else {
            stringBuilder.append(this.messageReturn((String) deliverableMap.get("deliverable_sub_type")));
        }
        xls.writeString(sheet, stringBuilder.toString());
        xls.nextColumn();

        // Partner Responsible
        xls.writeString(sheet, (String) deliverableMap.get("partner_responsible"));
        xls.nextColumn();

        // Other Partner
        xls.writeString(sheet, (String) deliverableMap.get("other_responsibles"));
        xls.nextColumn();

        xls.nextRow();

    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.ImpactPathwayContributionsSummaryXLS.java

License:Open Source License

/**
 * This method is used to add a project with its corresponding gender contribution
 * //  w  ww . j a v a2  s  .co m
 * @param sheet is the workbook sheet where the information is going to be presented
 * @param projectMapInformation is the list with the projects related to each institution
 */
private void addContent(List<Map<String, Object>> projectMapInformation, Sheet sheet) {

    Map<String, Object> projectMap;

    int projectID;
    CreationHelper createHelper = sheet.getWorkbook().getCreationHelper();
    XSSFHyperlink link;

    // ************************* Project Level Gender Contribution ***********************
    for (int i = 0; i < projectMapInformation.size(); i++) {
        projectMap = projectMapInformation.get(i);

        projectID = (int) projectMap.get("project_id");
        link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
        link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectID);

        // Project id
        xls.writeHyperlink(sheet, "P" + String.valueOf(projectID), link);
        xls.nextColumn();

        // Project title
        xls.writeString(sheet, (String) projectMap.get("project_title"));
        xls.nextColumn();

        // Flagship
        xls.writeString(sheet, (String) projectMap.get("flagship"));
        xls.nextColumn();

        // Outcome 2019
        xls.writeString(sheet, (String) projectMap.get("outcome_2019"));
        xls.nextColumn();

        // indicator
        xls.writeString(sheet, (String) projectMap.get("indicator"));
        xls.nextColumn();

        // target
        xls.writeString(sheet, (String) projectMap.get("target"));
        xls.nextColumn();

        // target narrative
        xls.writeString(sheet, (String) projectMap.get("target_narrative"));
        xls.nextColumn();

        // target gender
        xls.writeString(sheet, (String) projectMap.get("target_gender"));

        xls.nextRow();
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.LeadProjectPartnersSummaryXLS.java

License:Open Source License

/**
 * This method is used to add an institution being a project leader
 * /*from   w w  w  . j a  v  a2 s  .c o  m*/
 * @param projectLeadingInstitutions is the list of institutions to be added
 * @param projectList is the list with the projects related to each institution
 */
private void addContent(Sheet sheet, List<Map<String, Object>> projectList) {
    XSSFHyperlink link;
    CreationHelper createHelper = sheet.getWorkbook().getCreationHelper();
    Map<String, Object> projectPartnerLeader;
    String projectId;
    for (int i = 0; i < projectList.size(); i++) {
        projectPartnerLeader = projectList.get(i);
        projectId = projectPartnerLeader.get("project_id").toString();
        link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
        link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectId);
        xls.writeHyperlink(sheet, "P" + projectId, link);
        xls.nextColumn();
        xls.writeString(sheet, (String) projectPartnerLeader.get("start_date"));
        xls.nextColumn();
        xls.writeString(sheet, (String) projectPartnerLeader.get("end_date"));
        xls.nextColumn();
        xls.writeString(sheet, (String) projectPartnerLeader.get("project_title"));
        xls.nextColumn();
        xls.writeString(sheet, projectPartnerLeader.get("project_type").toString().replace("_", " "));
        xls.nextColumn();
        xls.writeString(sheet, (String) projectPartnerLeader.get("project_summary"));
        xls.nextColumn();
        xls.writeString(sheet, (String) projectPartnerLeader.get("flagships"));
        xls.nextColumn();
        xls.writeString(sheet, (String) projectPartnerLeader.get("regions"));
        xls.nextColumn();
        xls.writeString(sheet, (String) projectPartnerLeader.get("lead_institution"));
        xls.nextColumn();
        xls.writeString(sheet, (String) projectPartnerLeader.get("project_leader"));
        xls.nextColumn();
        xls.writeString(sheet, (String) projectPartnerLeader.get("project_coordinator"));
        xls.nextColumn();
        xls.writeBudget(sheet, (double) projectPartnerLeader.get("budget_w1w2"));
        xls.nextColumn();
        xls.writeBudget(sheet, (double) projectPartnerLeader.get("budget_w3bilateral"));
        xls.nextRow();
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.ProjectsNotModifiedSummaryXLS.java

License:Open Source License

/**
 * This method is used to add a project with its corresponding gender contribution
 * /* ww w  .j  a  v a  2s  .c  o  m*/
 * @param sheet is the workbook sheet where the information is going to be presented
 * @param informationList is the list with the projects related to each institution
 */
private void addContent(List<Map<String, Object>> informationList, Sheet sheet) {

    int projectID;
    CreationHelper createHelper = sheet.getWorkbook().getCreationHelper();
    Map<String, Object> projectMap;
    XSSFHyperlink link;
    // ************************* Project Level Submission Project ***********************
    for (int i = 0; i < informationList.size(); i++) {
        projectMap = informationList.get(i);

        projectID = (int) projectMap.get("project_id");
        link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
        link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectID);

        // Project id
        xls.writeHyperlink(sheet, "P" + String.valueOf(projectID), link);
        xls.nextColumn();

        xls.writeString(sheet, (String) projectMap.get("project_title"));
        xls.nextColumn();

        xls.writeString(sheet, (String) projectMap.get("project_summary"));
        xls.nextColumn();

        xls.writeString(sheet, ((String) projectMap.get("project_type")).replace("_", " "));

        xls.nextRow();
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.SearchTermsSummaryXLS.java

License:Open Source License

/**
 * This method is used to add a project with its corresponding gender contribution
 * //from   ww w.  j a  v a2 s .  com
 * @param sheet is the workbook sheet where the information is going to be presented
 * @param informationList is the list with the projects related to each institution
 */
private void addContent(List<Map<String, Object>> informationList, Sheet sheet, int sheetIndex,
        String[] terms) {

    Map<String, Object> projectContribution, activityContribution, deliverableContribution;

    for (int counter = 0; counter < terms.length; counter++) {
        terms[counter] = terms[counter].toLowerCase();
    }

    int projectID, deliverableID;
    CreationHelper createHelper = sheet.getWorkbook().getCreationHelper();
    XSSFHyperlink link; // = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
    if (sheetIndex == 0) {
        // ************************* Project Level Gender Contribution ***********************
        for (int i = 0; i < informationList.size(); i++) {
            projectContribution = informationList.get(i);

            projectID = (int) projectContribution.get("project_id");
            link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
            link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectID);

            // Project id
            xls.writeHyperlink(sheet, "P" + String.valueOf(projectID), link);
            xls.nextColumn();

            xls.writeSearchString(sheet, (String) projectContribution.get("project_title"), terms);
            xls.nextColumn();

            xls.writeSearchString(sheet, (String) projectContribution.get("project_summary"), terms);
            xls.nextColumn();

            xls.writeSearchString(sheet, (String) projectContribution.get("outcome_statement"), terms);
            xls.nextColumn();

            xls.writeString(sheet, (String) projectContribution.get("start_date"));
            xls.nextColumn();
            xls.writeString(sheet, (String) projectContribution.get("end_date"));
            xls.nextColumn();
            xls.writeString(sheet, (String) projectContribution.get("flagships"));
            xls.nextColumn();
            xls.writeString(sheet, (String) projectContribution.get("regions"));
            xls.nextColumn();
            xls.writeString(sheet, (String) projectContribution.get("lead_institution"));
            xls.nextColumn();
            xls.writeString(sheet, (String) projectContribution.get("project_leader"));
            xls.nextColumn();
            xls.writeString(sheet, (String) projectContribution.get("project_coordinator"));
            xls.nextColumn();
            xls.writeBudget(sheet, (double) projectContribution.get("budget_w1w2"));
            xls.nextColumn();
            xls.writeBudget(sheet, (double) projectContribution.get("budget_w3bilateral"));
            xls.nextColumn();
            xls.writeBudget(sheet, (double) projectContribution.get("gender_w1w2"));
            xls.nextColumn();
            xls.writeBudget(sheet, (double) projectContribution.get("gender_w3bilateral"));
            xls.nextRow();
        }
    } else if (sheetIndex == 1) {

        // ************************* Activity Level Gender Contribution ***********************
        for (int i = 0; i < informationList.size(); i++) {
            activityContribution = informationList.get(i);

            projectID = (int) activityContribution.get("project_id");
            link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
            link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectID);

            // Project id
            xls.writeHyperlink(sheet, "P" + String.valueOf(projectID), link);
            xls.nextColumn();

            xls.writeSearchString(sheet, (String) activityContribution.get("project_title"), terms);
            xls.nextColumn();

            // Activity id
            link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
            link.setAddress(config.getBaseUrl() + "/planning/projects/activities.do?projectID=" + projectID);
            xls.writeHyperlink(sheet,
                    "P" + String.valueOf(projectID) + "-" + "A" + (int) activityContribution.get("activity_id"),
                    link);
            xls.nextColumn();

            xls.writeSearchString(sheet, (String) activityContribution.get("activity_title"), terms);
            xls.nextColumn();
            xls.writeSearchString(sheet, (String) activityContribution.get("activity_description"), terms);
            xls.nextColumn();
            xls.writeString(sheet, (String) activityContribution.get("activity_startDate"));
            xls.nextColumn();
            xls.writeString(sheet, (String) activityContribution.get("activity_endDate"));
            xls.nextColumn();
            xls.writeString(sheet, (String) activityContribution.get("institution"));
            xls.nextColumn();
            xls.writeString(sheet, (String) activityContribution.get("activity_leader"));

            xls.nextRow();
        }
    } else if (sheetIndex == 2) {
        // ************************* Deliverable Level Gender Contribution ***********************
        for (int i = 0; i < informationList.size(); i++) {
            deliverableContribution = informationList.get(i);

            projectID = (int) deliverableContribution.get("project_id");
            link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
            link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectID);

            // Project id
            xls.writeHyperlink(sheet, "P" + String.valueOf(projectID), link);
            xls.nextColumn();

            xls.writeSearchString(sheet, (String) deliverableContribution.get("project_title"), terms);
            xls.nextColumn();

            // Deliverable id
            deliverableID = (int) deliverableContribution.get("deliverable_id");
            link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
            link.setAddress(
                    config.getBaseUrl() + "/planning/projects/deliverable.do?deliverableID=" + deliverableID);
            xls.writeHyperlink(sheet,
                    "P" + String.valueOf(projectID) + "-" + "D" + String.valueOf(deliverableID), link);
            xls.nextColumn();

            xls.writeSearchString(sheet, (String) deliverableContribution.get("deliverable_title"), terms);
            xls.nextColumn();
            xls.writeString(sheet, (String) deliverableContribution.get("deliverable_type"));
            xls.nextColumn();
            xls.writeString(sheet, (String) deliverableContribution.get("deliverable_subtype"));
            xls.nextColumn();
            xls.writeSearchString(sheet, (String) deliverableContribution.get("next_user"), terms);
            xls.nextColumn();
            xls.writeSearchString(sheet, (String) deliverableContribution.get("expected_changes"), terms);
            xls.nextColumn();
            xls.writeSearchString(sheet, (String) deliverableContribution.get("strategies"), terms);
            xls.nextColumn();
            xls.writeString(sheet, (String) deliverableContribution.get("institution"));
            xls.nextColumn();
            xls.writeString(sheet, (String) deliverableContribution.get("deliverable_responsible"));

            xls.nextRow();
        }
    }

}

From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.SubmissionProjectSummaryXLS.java

License:Open Source License

/**
 * This method is used to add a project with its corresponding gender contribution
 * //from  ww w .j a  v a2s. c o m
 * @param sheet is the workbook sheet where the information is going to be presented
 * @param informationList is the list with the projects related to each institution
 */
private void addContent(List<Map<String, Object>> informationList, Sheet sheet) {

    int projectID;
    CreationHelper createHelper = sheet.getWorkbook().getCreationHelper();
    Map<String, Object> projectMap;
    XSSFHyperlink link;
    DateFormat formatter = new SimpleDateFormat(APConstants.DATE_TIME_FORMAT_TIMEZONE);
    // ************************* Project Level Submission Project ***********************
    for (int i = 0; i < informationList.size(); i++) {
        projectMap = informationList.get(i);

        projectID = (int) projectMap.get("project_id");
        link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
        link.setAddress(config.getBaseUrl() + "/planning/projects/description.do?projectID=" + projectID);

        // Project id
        xls.writeHyperlink(sheet, "P" + String.valueOf(projectID), link);
        xls.nextColumn();

        xls.writeString(sheet, (String) projectMap.get("project_title"));
        xls.nextColumn();

        xls.writeString(sheet, (String) projectMap.get("project_summary"));
        xls.nextColumn();

        xls.writeString(sheet, (String) projectMap.get("project_type"));
        xls.nextColumn();

        xls.writeString(sheet, (String) projectMap.get("submmited_by"));
        xls.nextColumn();

        xls.writeString(sheet, formatter.format((Date) projectMap.get("submmited_on")));

        xls.nextRow();
    }
}