List of usage examples for org.apache.poi.xssf.usermodel XSSFCell setCellValue
@Override public void setCellValue(boolean value)
From source file:com.saba.CalendarDemo.java
License:Apache License
private static void prepareContactDetailsTableAndData(Map<String, Object> data, XSSFSheet sheet, Map<String, CellStyle> styles) { XSSFRow titleRow = sheet.createRow(0); titleRow.setHeightInPoints(16);//from w w w . j a va 2 s. c o m for (int i = 0; i <= 1; i++) { titleRow.createCell(i).setCellStyle(styles.get("title")); } XSSFCell titleCell = titleRow.getCell(0); titleCell.setCellValue(awardHeaders[0].toString()); sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$B$1")); for (int i = 0; i < contactDetails.length; i++) { XSSFRow row = sheet.createRow(i + 1); XSSFCell cell = row.createCell(0); cell.setCellValue(contactDetails[i].toString()); cell.setCellStyle(styles.get("item_left")); cell = row.createCell(1); populateDynamicObject(cell, data.get(contactDetails[i])); cell.setCellStyle(styles.get("item_right")); } }
From source file:com.saba.CalendarDemo.java
License:Apache License
private static void prepareAwardBidDetailsTableAndData(Map<String, Object> data, XSSFSheet sheet, Map<String, CellStyle> styles, int contactdetrow) { XSSFRow titleRow;/*from w ww .jav a 2s . co m*/ XSSFCell titleCell; titleRow = sheet.createRow(contactdetrow); titleRow.setHeightInPoints(16); for (int i = 0; i <= 1; i++) { titleRow.createCell(i).setCellStyle(styles.get("title")); } titleCell = titleRow.getCell(0); titleCell.setCellValue(awardHeaders[1].toString()); sheet.addMergedRegion(CellRangeAddress.valueOf("$A$" + (contactdetrow + 1) + ":$B$" + (contactdetrow + 1))); for (int i = 0; i < awardedBidDetails.length; i++) { XSSFRow row = sheet.createRow(contactdetrow + i + 1); XSSFCell cell = row.createCell(0); cell.setCellValue(awardedBidDetails[i]); cell.setCellStyle(styles.get("item_left")); cell = row.createCell(1); populateDynamicObject(cell, data.get(awardedBidDetails[i])); cell.setCellStyle(styles.get("item_right")); } }
From source file:com.saba.CalendarDemo.java
License:Apache License
private static void prepareProductDetailsTable(XSSFWorkbook workbook, XSSFSheet sheet, Map<String, CellStyle> styles, int awardDetailsRow) { XSSFRow titleRow;//from w w w . ja v a 2 s. c o m XSSFCell titleCell; titleRow = sheet.createRow(awardDetailsRow); titleRow.setHeightInPoints(16); for (int i = 0; i < productDetailsHeaders.length; i++) { titleRow.createCell(i).setCellStyle(styles.get("title")); } titleCell = titleRow.getCell(0); titleCell.setCellValue(awardHeaders[2].toString()); String columId = productDetailsHeaders.length > 0 && productDetailsHeaders.length < 27 ? String.valueOf((char) (productDetailsHeaders.length + 'A' - 1)) : null; String cellMergeRange = "$A$" + (awardDetailsRow + 1) + ":$" + columId + "$" + (awardDetailsRow + 1); sheet.addMergedRegion(CellRangeAddress.valueOf(cellMergeRange)); XSSFRow row = sheet.createRow(awardDetailsRow + 1); for (int i = 0; i < productDetailsHeaders.length; i++) { XSSFCell cell = row.createCell(i); cell.setCellValue(productDetailsHeaders[i]); //create header style for product Details table CellStyle headerStyle = createHeaderStyleForAward(workbook); cell.setCellStyle(headerStyle); } }
From source file:com.solidmaps.webapp.report.utils.ExcelMapCivilGenerator.java
private void createCell(XSSFRow row, Integer index, String value) { XSSFCell cell = row.createCell(index); cell.setCellStyle(styleProductList); cell.setCellValue(value); }
From source file:com.solidmaps.webapp.report.utils.ExcelMapCivilGenerator.java
private void createCellProduct(XSSFSheet sheetBuy, XSSFRow row, Integer index, String value) { XSSFCell cell = row.createCell(index); sheetBuy.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), 0, 3)); cell.setCellStyle(styleProductList); cell.setCellValue(value); }
From source file:com.solidmaps.webapp.report.utils.ExcelMapCivilGenerator.java
private void createCellUtilization(XSSFSheet sheetBuy, XSSFRow row, String value) { XSSFCell cell = row.createCell(7); sheetBuy.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), 7, 8)); cell.setCellStyle(styleProductList); cell.setCellValue(value); }
From source file:com.solidmaps.webapp.report.utils.ExcelMapCivilGenerator.java
private void createCellSell(XSSFSheet sheetBuy, XSSFRow row, String value) { XSSFCell cell = row.createCell(9); sheetBuy.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), 9, 11)); cell.setCellStyle(styleProductList); cell.setCellValue(value); }
From source file:com.solidmaps.webapp.report.utils.ExcelMapCivilGenerator.java
private void createCellNextTrimester(XSSFSheet sheetBuy, XSSFRow row, String value) { XSSFCell cell = row.createCell(12); sheetBuy.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), 12, 13)); cell.setCellStyle(styleProductList); cell.setCellValue(value); }
From source file:com.xidu.framework.common.view.documenthandler.AbstractExcel2007DocumentHandler.java
License:Open Source License
/** * Convenient method to set a String as text content in a cell. * @param cell the cell in which the text must be put * @param text the text to put in the cell *///from www . jav a 2 s.c o m protected void setText(XSSFCell cell, String text) { cell.setCellType(cell.getCellType()); cell.setCellValue(text); }
From source file:com.yyl.common.utils.excel.ExcelTools.java
/** * ?xlsxExcel/*from ww w. ja va 2s .c o m*/ * @param heads * @param data ? * @param sheetName Excel? * @param out ? * @return ByteArrayOutputStream * @throws IOException */ public static void writeToXLSX(ExcelRow heads, ExcelData data, String sheetName, ByteArrayOutputStream out) throws IOException { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet1 = wb.createSheet(sheetName); XSSFRow row = sheet1.createRow(0); XSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); XSSFCell cell; for (int i = 0; i < heads.size(); i++) { cell = row.createCell(i); cell.setCellValue(heads.get(i)); cell.setCellStyle(style); } if (data != null && data.size() != 0) { for (int n = 0; n < data.size(); n++) { row = sheet1.createRow(n + 1); ExcelRow datarow = data.get(n); for (int m = 0; m < datarow.size(); m++) { cell = row.createCell(m); cell.setCellValue(datarow.get(m)); cell.setCellStyle(style); } } } wb.write(out); }