List of usage examples for org.apache.poi.ss.usermodel Sheet getWorkbook
Workbook getWorkbook();
From source file:org.bbreak.excella.trans.tag.sheet2sql.SheetToSqlExecuter.java
License:Open Source License
/** * ??<BR>/*from w w w . java2s . c o m*/ * ?????Sql????<BR> * ????SheetData??<BR> * * @param sheet * @param sheetParser * @param sheetData ?? */ @SuppressWarnings("unchecked") public void postParse(Sheet sheet, SheetParser sheetParser, SheetData sheetData) throws ParseException { // ?? List<Object> results = new ArrayList<Object>(); // ?SheetToSqlParser??? List<TagParser<?>> tagParsers = sheetParser.getTagParsers(); // ?????SheetToJavaSettingParser? // ?? List<String> removeTags = new ArrayList<String>(); // ???? List<String> targetTags = new ArrayList<String>(); for (TagParser<?> tagParser : tagParsers) { // SheetToSqlParser? if (tagParser instanceof SheetToSqlParser) { targetTags.add(tagParser.getTag()); } // SheetToSqlSettingParser? if (tagParser instanceof SheetToSqlSettingParser) { removeTags.add(tagParser.getTag()); } } // ?? Workbook workbook = sheet.getWorkbook(); // ??? for (String tag : targetTags) { List<SheetToSqlParseInfo> sheetInfoList = (List<SheetToSqlParseInfo>) sheetData.get(tag); if (sheetInfoList == null) { continue; } // ()??? for (SheetToSqlParseInfo sheetInfo : sheetInfoList) { List<SheetToSqlSettingInfo> allColumnInfoList = (List<SheetToSqlSettingInfo>) sheetData .get(sheetInfo.getSettingTagName()); // ??? List<SheetToSqlSettingInfo> targetColumnInfoList = new ArrayList<SheetToSqlSettingInfo>(); for (SheetToSqlSettingInfo columnInfo : allColumnInfoList) { if (columnInfo.getSheetName().equals(sheetInfo.getSheetName())) { targetColumnInfoList.add(columnInfo); } } // ??? Sheet targetSheet = workbook.getSheet(sheetInfo.getSheetName()); if (targetSheet == null) { throw new ParseException("[" + sheetInfo.getSheetName() + "]????"); } results.addAll(parseTargetSheet(targetSheet, sheetInfo, targetColumnInfoList)); } // sheetData??? sheetData.put(tag, results); } // ??????? for (String removeTag : removeTags) { sheetData.remove(removeTag); } }
From source file:org.bbreak.excella.trans.tag.sheet2sql.SheetToSqlParser.java
License:Open Source License
/** * ?// www . j a v a 2s .c o m * * @param sheet * @param tagCell ??? * @param data TransProcessor?processBook, processSheet?<BR> * ????TagParser.parse??????<BR> * @return ? * @throws ParseException */ @Override public List<SheetToSqlParseInfo> parse(Sheet sheet, Cell tagCell, Object data) throws ParseException { // ? int tagRowIdx = tagCell.getRowIndex(); int tagColIdx = tagCell.getColumnIndex(); int valueRowFromIdx; int valueRowToIdx = sheet.getLastRowNum(); // ???? String settingTagName = getTag() + DEFAULT_SETTING_SUFFIX; try { Map<String, String> paramDef = TagUtil.getParams(tagCell.getStringCellValue()); // ? valueRowFromIdx = TagUtil.adjustValue(tagRowIdx, paramDef, PARAM_DATA_ROW_FROM, DEFAULT_DATA_ROW_FROM_ADJUST); if (valueRowFromIdx < 0 || valueRowFromIdx > sheet.getLastRowNum()) { throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_FROM); } // ? valueRowToIdx = TagUtil.adjustValue(tagRowIdx, paramDef, PARAM_DATA_ROW_TO, valueRowToIdx - tagRowIdx); if (valueRowToIdx > sheet.getLastRowNum() || valueRowToIdx < 0) { throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_TO); } // ??? if (valueRowFromIdx > valueRowToIdx) { throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_FROM + "," + PARAM_DATA_ROW_TO); } // ???? if (paramDef.containsKey(PARAM_SETTING_TAG_NAME)) { settingTagName = paramDef.get(PARAM_SETTING_TAG_NAME); } // ? if (paramDef.containsKey(PARAM_RESULT_KEY)) { // ??????? throw new ParseException(tagCell, PARAM_RESULT_KEY + "????????"); } } catch (Exception e) { if (e instanceof ParseException) { throw (ParseException) e; } else { throw new ParseException(tagCell, e); } } List<SheetToSqlParseInfo> sheetInfoList = new ArrayList<SheetToSqlParseInfo>(); // ?? int sheetNameColIdx = tagColIdx++; // ???No int logicalRowColIdx = tagColIdx++; // No int dataRowColIdx = tagColIdx; // ????? Workbook workbook = sheet.getWorkbook(); // ??? for (int rowNum = valueRowFromIdx; rowNum <= valueRowToIdx; rowNum++) { Row row = sheet.getRow(rowNum); if (row != null) { // ?? Cell sheetNameCell = row.getCell(sheetNameColIdx); Cell logicalRowNumCell = row.getCell(logicalRowColIdx); Cell valueRowNumCell = row.getCell(dataRowColIdx); // ? if ((sheetNameCell == null) && (logicalRowNumCell == null) && (valueRowNumCell == null)) { // ????null?? continue; } else if ((sheetNameCell == null) || (sheetNameCell.getStringCellValue() == null) || ("".equals(sheetNameCell.getStringCellValue()))) { // ????????? continue; } else { // ???? Cell requiredErrorCell = null; if (logicalRowNumCell == null) { requiredErrorCell = row.createCell(logicalRowColIdx); } else if (valueRowNumCell == null) { requiredErrorCell = row.createCell(dataRowColIdx); } // ?????? if (requiredErrorCell != null) { throw new ParseException(requiredErrorCell, "?null??"); } } // ???No? int logicalRowNum; try { logicalRowNum = (Integer) PoiUtil.getCellValue(logicalRowNumCell, Integer.class); } catch (Exception e) { throw new ParseException(logicalRowNumCell, e); } // No? int valueRowNum; try { valueRowNum = (Integer) PoiUtil.getCellValue(valueRowNumCell, Integer.class); } catch (Exception e) { throw new ParseException(valueRowNumCell, e); } // ??? String sheetName = sheetNameCell.getStringCellValue(); if (workbook.getSheet(sheetName) == null) { throw new ParseException(sheetNameCell, "[" + sheetName + "]????"); } // SheetToSqlParseInfo sheetInfo = new SheetToSqlParseInfo(); sheetInfo.setSettingTagName(settingTagName); sheetInfo.setSheetName(sheetName); sheetInfo.setLogicalNameRowNum(logicalRowNum); sheetInfo.setValueRowNum(valueRowNum); sheetInfoList.add(sheetInfo); } } return sheetInfoList; }
From source file:org.bbreak.excella.trans.tag.sheet2sql.SheetToSqlSettingParser.java
License:Open Source License
/** * ?/*from w w w.jav a 2 s . com*/ * * @param sheet * @param tagCell ??? * @param data TransProcessor?processBook, processSheet?<BR> * ????TagParser.parse??????<BR> * @return ? * @throws ParseException */ @Override public List<SheetToSqlSettingInfo> parse(Sheet sheet, Cell tagCell, Object data) throws ParseException { // ? int tagRowIdx = tagCell.getRowIndex(); int tagColIdx = tagCell.getColumnIndex(); // int valueRowFromIdx; int valueRowToIdx = sheet.getLastRowNum(); try { Map<String, String> paramDef = TagUtil.getParams(tagCell.getStringCellValue()); // ? valueRowFromIdx = TagUtil.adjustValue(tagRowIdx, paramDef, PARAM_DATA_ROW_FROM, DEFAULT_DATA_ROW_FROM_ADJUST); if (valueRowFromIdx < 0 || valueRowFromIdx > sheet.getLastRowNum()) { throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_TO); } // ? valueRowToIdx = TagUtil.adjustValue(tagRowIdx, paramDef, PARAM_DATA_ROW_TO, valueRowToIdx - tagRowIdx); if (valueRowToIdx > sheet.getLastRowNum() || valueRowToIdx < 0) { throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_TO); } // ??? if (valueRowFromIdx > valueRowToIdx) { throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_FROM + "," + PARAM_DATA_ROW_TO); } } catch (Exception e) { if (e instanceof ParseException) { throw (ParseException) e; } else { throw new ParseException(tagCell, e); } } List<SheetToSqlSettingInfo> sheetSettingInfoList = new ArrayList<SheetToSqlSettingInfo>(); // ?? int sheetNameColIdx = tagColIdx++; // int valueColIdx = tagColIdx++; // int tableColIdx = tagColIdx++; // int columnNameColIdx = tagColIdx++; // ??? int uniqueColIdx = tagColIdx++; // int dataTypeColIdx = tagColIdx++; // ????? Workbook workbook = sheet.getWorkbook(); // ??? for (int rowNum = valueRowFromIdx; rowNum <= valueRowToIdx; rowNum++) { Row row = sheet.getRow(rowNum); if (row != null) { // ?? Cell sheetNameCell = row.getCell(sheetNameColIdx); Cell valueCell = row.getCell(valueColIdx); Cell tableNameCell = row.getCell(tableColIdx); Cell columnNameCell = row.getCell(columnNameColIdx); Cell uniqueCell = row.getCell(uniqueColIdx); Cell dataTypeCell = row.getCell(dataTypeColIdx); // ? if ((sheetNameCell == null) && (valueCell == null) && (tableNameCell == null) && (columnNameCell == null) && (uniqueCell == null) && (dataTypeCell == null)) { // ????null?? continue; } else if ((sheetNameCell == null) || (sheetNameCell.getStringCellValue() == null) || ("".equals(sheetNameCell.getStringCellValue()))) { // ????????? continue; } else { // ???? Cell requiredErrorCell = null; if (tableNameCell == null) { // ?null?? requiredErrorCell = row.createCell(tableColIdx); } else if (columnNameCell == null) { // ?null?? requiredErrorCell = row.createCell(columnNameColIdx); } if (requiredErrorCell != null) { // ?? throw new ParseException(requiredErrorCell, "?null??"); } } // ?? SheetToSqlSettingInfo settingInfo = new SheetToSqlSettingInfo(); // ???? String sheetName = sheetNameCell.getStringCellValue(); if (workbook.getSheet(sheetName) == null) { throw new ParseException(sheetNameCell, "[" + sheetName + "]????"); } // ?? settingInfo.setSheetName(sheetName); settingInfo.setSheetNameCell(sheetNameCell); // ?? settingInfo.setTableName(tableNameCell.getStringCellValue()); settingInfo.setTableNameCell(tableNameCell); // settingInfo.setColumnName(columnNameCell.getStringCellValue()); settingInfo.setColumnNameCell(columnNameCell); // if (valueCell != null) { Object value = PoiUtil.getCellValue(valueCell); settingInfo.setValue(value); settingInfo.setValueCell(valueCell); } // ??? if (uniqueCell != null) { if (uniqueCell.getStringCellValue() != null && uniqueCell.getStringCellValue().equals(UNIQUE_PROPERTY_MARK)) { settingInfo.setUnique(true); settingInfo.setUniqueCell(uniqueCell); } } // if (dataTypeCell != null) { settingInfo.setDataType(dataTypeCell.getStringCellValue()); settingInfo.setDataTypeCell(dataTypeCell); } // ???? sheetSettingInfoList.add(settingInfo); } } return sheetSettingInfoList; }
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 w w. j a v a 2 s.c o m*/ 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.BudgetPerPartnersSummaryXLS.java
License:Open Source License
/** * This method is used to add an institution being a project leader * /*from w ww. j av 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>> 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.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 . com*/ * @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 * // w w w. j ava 2 s.co 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.NoLoggedInPartnersSummaryXLS.java
License:Open Source License
/** * This method is used to add each partner not having logged in P&R * /*from w w w . j ava2 s . c o m*/ * @param noLoggedInPartnersList is the list of partners to be added * @param sheet is the workbook sheet in which the information is going to be added */ private void addContent(List<Map<String, Object>> noLoggedInPartnersList, Sheet sheet) { CreationHelper createHelper = sheet.getWorkbook().getCreationHelper(); XSSFHyperlink link; Map<String, Object> mapObject; int projectID; for (int a = 0; a < noLoggedInPartnersList.size(); a++) { mapObject = noLoggedInPartnersList.get(a); // User Id xls.writeInteger(sheet, (int) (mapObject.get("user_id"))); xls.nextColumn(); // Name xls.writeString(sheet, (String) mapObject.get("name")); xls.nextColumn(); // Email xls.writeString(sheet, (String) mapObject.get("email")); xls.nextColumn(); // Contact type xls.writeString(sheet, (String) mapObject.get("contact_type")); xls.nextColumn(); // Project id xls.writeString(sheet, (String) mapObject.get("project_id")); 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 . ja v a 2 s . 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 w w w . j a v a2 s .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 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(); } } }