List of usage examples for org.apache.poi.xssf.usermodel XSSFWorkbook cloneSheet
@Override public XSSFSheet cloneSheet(int sheetNum)
From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.BudgetByMOGSummaryXLS.java
License:Open Source License
/** * This method is used to generate the csv file for the ProjectLeading institutions. * //from www.j a v a 2 s. c om * @param projectPartnerInstitutions is the list of institutions to be added * @param projectList is the list with the projects related to each institution */ public byte[] generateXLS(List<Map<String, Object>> informationBudgetReportByMOGDetail, List<Map<String, Object>> informationBudgetReportByMOG) { try { XSSFWorkbook workbook = xls.initializeWorkbook(true); /***************** Budget Summary By MOG Report ******************/ // Writting headers String[] headersPOWB = new String[] { "Outcome 2019", "MOG", "Total Budget W1/W2 (USD)", "Gender W1/W2 (USD)", "Total Budget W3/Bilateral (USD)", "Gender W3/Bilateral (USD)" }; // defining header types. int[] headerTypesPOWB = new int[] { BaseXLS.COLUMN_TYPE_TEXT_LONG, BaseXLS.COLUMN_TYPE_TEXT_LONG, BaseXLS.COLUMN_TYPE_BUDGET, BaseXLS.COLUMN_TYPE_BUDGET, BaseXLS.COLUMN_TYPE_BUDGET, BaseXLS.COLUMN_TYPE_BUDGET }; // creating sheet Sheet[] sheets = new Sheet[2]; sheets[0] = workbook.getSheetAt(0); sheets[1] = workbook.cloneSheet(0); workbook.setSheetName(0, "Level - 1 "); xls.initializeSheet(sheets[0], headerTypesPOWB); xls.writeHeaders(sheets[0], headersPOWB); this.addContent(informationBudgetReportByMOG, sheets[0], 0, workbook); // Set description xls.writeDescription(sheets[0], xls.getText("summaries.budget.summary.sheet.description")); // write text box xls.writeTitleBox(sheets[0], " \t\t Budget Summary"); // write text box xls.createLogo(workbook, sheets[0]); /***************** Budget Summary By MOG Detail ******************/ // Sheet cleanSheet = // Writting headers String[] headersPOWBDetail = new String[] { "Project Id", "Project title", "Project type", "MOG", "Expected annual contribution", "Expected plan of the gender and social inclusion", "Total Budget W1/W2 (USD)", " Gender W1/W2 (USD)", "Total Budget W3/Bilateral (USD)", "Gender W3/Bilateral (USD)" }; // defining header types. int[] headerTypesPOWBDetail = new int[] { BaseXLS.COLUMN_TYPE_HYPERLINK, BaseXLS.COLUMN_TYPE_TEXT_LONG, BaseXLS.COLUMN_TYPE_TEXT_SHORT, BaseXLS.COLUMN_TYPE_TEXT_LONG, BaseXLS.COLUMN_TYPE_TEXT_LONG, BaseXLS.COLUMN_TYPE_TEXT_LONG, BaseXLS.COLUMN_TYPE_BUDGET, BaseXLS.COLUMN_TYPE_BUDGET, BaseXLS.COLUMN_TYPE_BUDGET, BaseXLS.COLUMN_TYPE_BUDGET }; workbook.setSheetName(1, "Level - 2"); xls.initializeSheet(sheets[1], headerTypesPOWBDetail); xls.writeHeaders(sheets[1], headersPOWBDetail); this.addContent(informationBudgetReportByMOGDetail, sheets[1], 1, workbook); // Set description xls.writeDescription(sheets[1], xls.getText("summaries.budget.summary.sheet.description")); // write text box xls.writeTitleBox(sheets[1], " Budget Summary Detail"); // write text box xls.createLogo(workbook, sheets[1]); // this.flush(); xls.writeWorkbook(); byte[] byteArray = xls.getBytes(); // Closing streams. xls.closeStreams(); return byteArray; } catch (IOException e) { e.printStackTrace(); } return null; }