List of usage examples for org.apache.poi.xssf.usermodel XSSFFont setBold
public void setBold(boolean bold)
From source file:ru.jeene.zapretparser.controller.XLSXReportController.java
public void WriteReport(FullReport rep, String timestamp_csv) { try (FileInputStream inp = new FileInputStream(shab_name)) { XSSFWorkbook wb = new XSSFWorkbook(inp); // Declare XSSF WorkBook XSSFSheet sheet = wb.getSheet(" "); XSSFCellStyle cs1 = wb.createCellStyle(); //cs1.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND); cs1.setBorderBottom(XSSFCellStyle.BORDER_THIN); cs1.setBorderTop(XSSFCellStyle.BORDER_THIN); cs1.setBorderRight(XSSFCellStyle.BORDER_THIN); cs1.setBorderLeft(XSSFCellStyle.BORDER_THIN); cs1.setAlignment(XSSFCellStyle.ALIGN_CENTER); cs1.setWrapText(true);//from ww w .ja v a2s . c om cs1.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); XSSFFont f = wb.createFont(); f.setBold(false); f.setFontName("Times New Roman"); f.setFontHeightInPoints((short) 14); cs1.setFont(f); int cnt = 0; XSSFRow row; XSSFCell cell; for (Model_FullReport m : rep.getList()) { int cnt_cell = 0; row = sheet.getRow(t1_start - 1 + cnt); if (row == null) { row = sheet.createRow(t1_start - 1 + cnt); } //? URL cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(m.getElement().getUrl()); cell.setCellStyle(cs1); cnt_cell++; // cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(m.getElement().getOrg()); cell.setCellStyle(cs1); cnt_cell++; //? cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(m.getElement().getDoc()); cell.setCellStyle(cs1); cnt_cell++; // cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(m.getElement().getDate()); cell.setCellStyle(cs1); cnt_cell++; // cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(m.getResult().name()); cell.setCellStyle(cs1); cnt_cell++; // (?) cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(m.getResult().getDesc()); cell.setCellStyle(cs1); cnt_cell++; // () cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(m.getResult().getCode()); cell.setCellStyle(cs1); cnt_cell++; cnt++; } // row = sheet.getRow(0); cell = row.getCell(0); cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(MAIN_ZAG_TEMPL + timestamp_csv); // HashMap<ResponseResult, Model_NumberReport> map = rep.reportCountBytype(); // ? sheet = wb.getSheet(""); // cnt = 0; for (Map.Entry<ResponseResult, Model_NumberReport> entry : map.entrySet()) { ResponseResult key = entry.getKey(); Model_NumberReport value = entry.getValue(); int cnt_cell = 0; row = sheet.getRow(t0_start - 1 + cnt); if (row == null) { row = sheet.createRow(t0_start - 1 + cnt); } /*// cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(key.name()); cell.setCellStyle(cs1); cnt_cell++;*/ // (?) cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(key.getDesc()); cell.setCellStyle(cs1); cnt_cell++; /*// () cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(key.getCode()); cell.setCellStyle(cs1); cnt_cell++;*/ // (?) cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(value.getNumber()); cell.setCellStyle(cs1); cnt_cell++; // () cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(FormatUtils.FormatDoubleD(value.getPercent())); cell.setCellStyle(cs1); cnt_cell++; cnt++; } // row = sheet.getRow(0); cell = row.getCell(0); cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(MAIN_ZAG_TEMPL + timestamp_csv); // HTTP map = rep.reportCountBytypeHTTP(); // ? sheet = wb.getSheet(" HTTP"); // cnt = 0; for (Map.Entry<ResponseResult, Model_NumberReport> entry : map.entrySet()) { ResponseResult key = entry.getKey(); Model_NumberReport value = entry.getValue(); int cnt_cell = 0; row = sheet.getRow(t0_start - 1 + cnt); if (row == null) { row = sheet.createRow(t0_start - 1 + cnt); } /*// cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(key.name()); cell.setCellStyle(cs1); cnt_cell++;*/ // (?) cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(key.getDesc()); cell.setCellStyle(cs1); cnt_cell++; /*// () cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(key.getCode()); cell.setCellStyle(cs1); cnt_cell++;*/ // (?) cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(value.getNumber()); cell.setCellStyle(cs1); cnt_cell++; // () cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(FormatUtils.FormatDoubleD(value.getPercent())); cell.setCellStyle(cs1); cnt_cell++; cnt++; } // row = sheet.getRow(0); cell = row.getCell(0); cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(MAIN_ZAG_TEMPL + timestamp_csv); // HTTPS map = rep.reportCountBytypeHTTPS(); // ? sheet = wb.getSheet(" HTTPS"); // cnt = 0; for (Map.Entry<ResponseResult, Model_NumberReport> entry : map.entrySet()) { ResponseResult key = entry.getKey(); Model_NumberReport value = entry.getValue(); int cnt_cell = 0; row = sheet.getRow(t0_start - 1 + cnt); if (row == null) { row = sheet.createRow(t0_start - 1 + cnt); } /*// cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(key.name()); cell.setCellStyle(cs1); cnt_cell++;*/ // (?) cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(key.getDesc()); cell.setCellStyle(cs1); cnt_cell++; /*// () cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(key.getCode()); cell.setCellStyle(cs1); cnt_cell++;*/ // (?) cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(value.getNumber()); cell.setCellStyle(cs1); cnt_cell++; // () cell = row.getCell(cnt_cell); if (cell == null) { cell = row.createCell(cnt_cell); } cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(FormatUtils.FormatDoubleD(value.getPercent())); cell.setCellStyle(cs1); cnt_cell++; cnt++; } // row = sheet.getRow(0); cell = row.getCell(0); cell.setCellType(XSSFCell.CELL_TYPE_STRING); cell.setCellValue(MAIN_ZAG_TEMPL + timestamp_csv); //? String tmp_out = StringUtils.replaceAll(report_name, "!dt!", DateUtils.DateToString(new Date(System.currentTimeMillis()), "ddMMyyyy_Hms")); try (FileOutputStream out = new FileOutputStream(tmp_out)) { wb.write(out); logger.info("Report file " + tmp_out + " created"); } } catch (Exception ex) { logger.error(ex); } }
From source file:se.inera.intyg.rehabstod.service.export.xlsx.XlsxExportServiceImpl.java
License:Open Source License
private XSSFFont buildFont(XSSFWorkbook wb, int heightInPoints, String fontName, boolean bold, boolean underline) { XSSFFont font = wb.createFont(); font.setFontHeightInPoints((short) heightInPoints); font.setFontName(fontName);//from ww w.j a v a2 s . c om font.setColor(IndexedColors.BLACK.getIndex()); font.setBold(bold); font.setBoldweight(bold ? Font.BOLDWEIGHT_BOLD : Font.BOLDWEIGHT_NORMAL); font.setUnderline(underline ? XSSFFont.U_SINGLE : XSSFFont.U_NONE); return font; }
From source file:se.minstrel.tools.xssfbuilder.style.impl.StyleBuilderImpl.java
License:Open Source License
private XSSFCellStyle buildStyle() { XSSFWorkbook wb = support.getWorkbook(); XSSFFont font = wb.createFont(); font.setFontName(style.getFont());//from w w w .j a va 2 s .com font.setFontHeightInPoints(style.getFontSize()); font.setBold(style.isBold()); font.setItalic(style.isItalics()); if (style.getFgColor() != null) { font.setColor(new XSSFColor(style.getFgColor())); } XSSFCellStyle cs = support.getWorkbook().createCellStyle(); cs.setFont(font); if (style.getBgColor() != null) { cs.setFillForegroundColor(new XSSFColor(style.getBgColor())); cs.setFillPattern(FillPatternType.SOLID_FOREGROUND); } if (style.getFormat() != null) { cs.setDataFormat(support.getDataFormat().getFormat(style.getFormat())); } // style.getBgColor(); // style.getFgColor(); // style.isBold(); // style.isItalics(); return cs; }
From source file:tools.IOHelper.java
public static void plate1ResultSheet(ANAPlate plate, File outputFolder) throws IOException { File outputFile = new File(outputFolder, plate.getPlateId() + "_" + TIME + ".xlsx"); Workbook excelFile = null;/* w w w . j ava2 s . c om*/ // if (outputFile.exists()) { // try { // excelFile = WorkbookFactory.create(outputFile); // } catch (EncryptedDocumentException ex) { // System.out.println("file with assigned name already exists but is encrypted..."); // Logger.getLogger(IOHelper.class.getName()).log(Level.SEVERE, null, ex); // } catch (InvalidFormatException ex) { // Logger.getLogger(IOHelper.class.getName()).log(Level.SEVERE, null, ex); // } // } else { // outputFile.createNewFile(); // excelFile = new XSSFWorkbook(); // } if (outputFile.exists()) { outputFile.delete(); } outputFile.createNewFile(); excelFile = new XSSFWorkbook(); if (excelFile == null) { throw new RuntimeException("fail to create the xlsx file"); } int rowCount = plate.getSampleNumber(); //not including the 2 control samples + "_"+time String sheetName = plate.getPlateId(); //create a working sheet Sheet sheet = excelFile.createSheet(sheetName); //starting row & col int rowIndex = 0; int colIndex = 0; int totalCol = 0; int pos = 0, neg = 0, all = 0; XSSFFont fontTitle = (XSSFFont) excelFile.createFont(); fontTitle.setFontHeightInPoints((short) 10); fontTitle.setFontName("Arial"); fontTitle.setColor(IndexedColors.GREEN.getIndex()); fontTitle.setBold(true); fontTitle.setItalic(false); XSSFCellStyle styleTitle = (XSSFCellStyle) excelFile.createCellStyle(); styleTitle.setAlignment(CellStyle.ALIGN_CENTER); styleTitle.setFont(fontTitle); Cell cell0 = sheet.createRow(rowIndex++).createCell(0); cell0.setCellValue(plate.getPlateId() + " Summary"); //title cell0.setCellStyle(styleTitle); // //optional set Cell Style // CellStyle styleTitle = null; // CellStyle style = null; Row row = sheet.createRow(rowIndex++); //names Cell column = row.createCell(colIndex++); column.setCellValue("Sample ID"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Chip Location"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Result"); totalCol++; // column = row.createCell(colIndex++); // column.setCellValue("Positivity 0.3P"); // totalCol++; // column = row.createCell(colIndex++); // column.setCellValue("Positivity0.275P+0.5N"); // totalCol++; column = row.createCell(colIndex++); column.setCellValue("Signal"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Comments"); totalCol++; for (ANATestResult result : plate.getTestResultList()) { row = sheet.createRow(rowIndex++); //data colIndex = 0; column = row.createCell(colIndex++); column.setCellValue(result.getJulien_barcode()); column = row.createCell(colIndex++); column.setCellValue(result.getPillarPosition()); column = row.createCell(colIndex++); if (result.getPositivity() == null) { column.setCellValue("Null Result"); } else { if (ANA_Result.POSITIVE.equals(result.getPositivity())) { pos++; } else if (ANA_Result.NEGATIVE.equals(result.getPositivity())) { neg++; } all++; column.setCellValue(result.getPositivity().name()); } //make sure all fis has not-null pn result // column = row.createCell(colIndex++); // if (result.positivity30 == null) { // column.setCellValue("Null Result"); // } else { // if (ANA_Result.POSITIVE.equals(result.positivity30)) { //// pos++; // } else if (ANA_Result.NEGATIVE.equals(result.positivity30)) { //// neg++; // } //// all++; // column.setCellValue(result.positivity30.name()); // } //make sure all fis has not-null pn result // column = row.createCell(colIndex++); // if (result.positivityCombined == null) { // column.setCellValue("Null Result"); // } else { // if (ANA_Result.POSITIVE.equals(result.positivityCombined)) { //// pos++; // } else if (ANA_Result.NEGATIVE.equals(result.positivityCombined)) { //// neg++; // } //// all++; // column.setCellValue(result.positivityCombined.name()); // } //make sure all fis has not-null pn result column = row.createCell(colIndex++); column.setCellValue(result.getFirstPlateSignal()); // if(result.getFirstPlateSignal()<0){ // column.setCellValue("ROI exception: unable to get signal for this sample"); // }else{ // column.setCellValue(result.getFirstPlateSignal()); // } column = row.createCell(colIndex++); //warning msg concat mthd; merge plateErr to sampErr column.setCellValue(result.concatWarningMsgs()); } if (rowIndex - rowCount == 2) { for (int i = 0; i < totalCol; i++) { sheet.autoSizeColumn(i); } } else { System.out .println((rowIndex - 2) + " records are writen into file while " + rowCount + " are expected"); } row = sheet.createRow(rowIndex++); //total colIndex = 0; column = row.createCell(colIndex++); column.setCellValue("all samples"); column = row.createCell(colIndex++); column.setCellValue(all); column = row.createCell(colIndex++); column.setCellValue("positive samples"); column = row.createCell(colIndex++); column.setCellValue(pos); column = row.createCell(colIndex++); column.setCellValue("negative samples"); column = row.createCell(colIndex++); column.setCellValue(neg); column = row.createCell(colIndex++); column = row.createCell(colIndex++); column = row.createCell(colIndex++); column.setCellValue("PosCtrl"); column = row.createCell(colIndex++); column.setCellValue(plate.getPosCtrl().getFirstPlateSignal()); column = row.createCell(colIndex++); column.setCellValue("NegCtrl"); column = row.createCell(colIndex++); column.setCellValue(plate.getNegCtrlSignal()); FileOutputStream fos = null; try { fos = new FileOutputStream(outputFile.getAbsolutePath());//,true excelFile.write(fos); } catch (FileNotFoundException ex) { Logger.getLogger(IOHelper.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(IOHelper.class.getName()).log(Level.SEVERE, null, ex); } finally { if (fos != null) { try { fos.close(); } catch (IOException ex) { Logger.getLogger(IOHelper.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:tools.IOHelper.java
public static void plate2ResultSheet(ANAPlate plate, File outputFolder) throws IOException { File outputFile = new File(outputFolder, plate.getPlateId() + "_" + TIME + ".xlsx"); Workbook excelFile = null;//from www. j a v a 2 s.c o m if (outputFile.exists()) { outputFile.delete(); } outputFile.createNewFile(); excelFile = new XSSFWorkbook(); if (excelFile == null) { throw new RuntimeException("fail to create the xlsx file"); } int rowCount = plate.getSampleNumber(); //not including the 2 control samples + "_"+time String sheetName = plate.getPlateId(); //create a working sheet Sheet sheet = excelFile.createSheet(sheetName); //starting row & col int rowIndex = 0; int colIndex = 0; int totalCol = 0; int pos = 0, neg = 0, all = 0; XSSFFont fontTitle = (XSSFFont) excelFile.createFont(); fontTitle.setFontHeightInPoints((short) 10); fontTitle.setFontName("Arial"); fontTitle.setColor(IndexedColors.GREEN.getIndex()); fontTitle.setBold(true); fontTitle.setItalic(false); XSSFCellStyle styleTitle = (XSSFCellStyle) excelFile.createCellStyle(); styleTitle.setAlignment(CellStyle.ALIGN_CENTER); styleTitle.setFont(fontTitle); Cell cell0 = sheet.createRow(rowIndex++).createCell(0); cell0.setCellValue(plate.getPlateId() + " Summary"); //title cell0.setCellStyle(styleTitle); // //optional set Cell Style // CellStyle styleTitle = null; // CellStyle style = null; // add column:Sample,Chip Location,Signal,Positivity,sample titer,plate titer, pattern, No of Cells, enableWatershed,comment Row row = sheet.createRow(rowIndex++); //names Cell column = row.createCell(colIndex++); column.setCellValue("Sample ID"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Chip Location"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Signal"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Positivity"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Sample Titer"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Plate Titer"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Pattern"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Number of Cells"); totalCol++; column = row.createCell(colIndex++); column.setCellValue("Comments"); totalCol++; for (ANATestResult result : plate.getTestResultList()) { row = sheet.createRow(rowIndex++); //data colIndex = 0; column = row.createCell(colIndex++); column.setCellValue(result.getJulien_barcode()); column = row.createCell(colIndex++); column.setCellValue(result.getPillarPosition()); column = row.createCell(colIndex++); column.setCellValue(result.getSecondPlateSignal()); column = row.createCell(colIndex++); if (result.getPositivity() == null) { column.setCellValue("Null Result"); } else { if (ANA_Result.POSITIVE.equals(result.getPositivity())) { pos++; } else if (ANA_Result.NEGATIVE.equals(result.getPositivity())) { neg++; } all++; column.setCellValue(result.getPositivity().name()); } //make sure all fis has not-null pn result column = row.createCell(colIndex++); if (result.getTiter() != null) { column.setCellValue(result.getTiter().name()); } column = row.createCell(colIndex++); if (plate.getPosCtrl().getTiter() != null) { column.setCellValue(plate.getPosCtrl().getTiter().name()); } //pattern, No of Cells, enableWatershed,comment column = row.createCell(colIndex++); if (result.getPattern() != null) { column.setCellValue(result.getPattern().name()); } column = row.createCell(colIndex++); column.setCellValue(result.cellCount()); column = row.createCell(colIndex++); //warning msg concat mthd; merge plateErr to sampErr column.setCellValue(result.concatWarningMsgs()); } if (rowIndex - rowCount == 2) { for (int i = 0; i < totalCol; i++) { sheet.autoSizeColumn(i); } } else { System.out .println((rowIndex - 2) + " records are writen into file while " + rowCount + " are expected"); } row = sheet.createRow(rowIndex++); //total colIndex = 0; column = row.createCell(colIndex++); column.setCellValue("all samples"); column = row.createCell(colIndex++); column.setCellValue(all); column = row.createCell(colIndex++); column.setCellValue("positive samples"); column = row.createCell(colIndex++); column.setCellValue(pos); column = row.createCell(colIndex++); column.setCellValue("negative samples"); column = row.createCell(colIndex++); column.setCellValue(neg); FileOutputStream fos = null; try { fos = new FileOutputStream(outputFile.getAbsolutePath());//,true excelFile.write(fos); } catch (FileNotFoundException ex) { Logger.getLogger(IOHelper.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(IOHelper.class.getName()).log(Level.SEVERE, null, ex); } finally { if (fos != null) { try { fos.close(); } catch (IOException ex) { Logger.getLogger(IOHelper.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:ve.zoonosis.utils.XLSCreator.java
License:Apache License
public void addRow(CeldaCustomizer... objs) { // int r, w; // final int n = r = w = objs.length; // while (r > 0) { // final CeldaCustomizer s = objs[--r]; // if (s != null) { // objs[--w] = s; // } // }/*from www. j a v a 2 s .c o m*/ // objs = Arrays.copyOfRange(objs, w, n); for (int i = 0; i < objs.length; i++) { if (objs[i] == null) { objs[i] = new CeldaCustomizer(""); } int inic = i; int fin = i; if (i > 1) { if (objs[i - 1].getColumn() != 1) { inic = i * objs[i - 1].getColumn() - 1; } } if (objs[i].getColumn() != 1) { CeldaCustomizer cc = objs[i]; fin = inic + cc.getColumn() - 1; } if (inic < fin) { CellRangeAddress cellRangeAddress = new CellRangeAddress(rowIndex, rowIndex, (inic), (fin)); sheet.addMergedRegion(cellRangeAddress); } } Row row = sheet.createRow(rowIndex++); if (rowIndex == 1) { sheet.setColumnWidth(0, 10000); } for (int i = 0; i < objs.length; i++) { int inic = i; if (i > 1) { if (objs[i - 1].getColumn() != 1) { inic = i * objs[i - 1].getColumn() - 1; } } XSSFFont font = wb.createFont(); XSSFCellStyle style = wb.createCellStyle(); font.setBold(objs[i].isBold()); style.setFont(font); Object obj = objs[i].getObj(); Cell cell = row.createCell(inic); cell.setCellStyle(style); if (obj instanceof String) { cell.setCellValue((String) obj); } else if (obj instanceof Boolean) { cell.setCellValue((Boolean) obj); } else if (obj instanceof Date) { cell.setCellValue((Date) obj); } else if (obj instanceof Double) { cell.setCellValue((Double) obj); } else if (obj instanceof Integer) { cell.setCellValue(Double.valueOf("" + (int) obj)); } } }