HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("FirstSheet"); HSSFRow rowhead= sheet.createRow((short)0); HSSFCellStyle style = workbook.createCellStyle(); style.setWrapText(true); row.setRowStyle(style); row.getCell(0).setCellStyle(style);
boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); HSSFCellStyle headerSyle = workbook.createCellStyle(); headerSyle.setBorderBottom(CellStyle.BORDER_THIN); headerSyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
HSSFCellStyle style = wb.createCellStyle(); style.setFillForegroundColor(HSSFColor.LIME.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
public static HSSFCellStyle adoptDetachedCellStyle(HSSFWorkbook workbook, HSSFCellStyle detachedCellStyle) { HSSFCellStyle cellStyle = workbook.createCellStyle(); XslStyleHelper.cloneStyleRelations(detachedCellStyle, cellStyle); return cellStyle; } }
private static HSSFCellStyle createCustomStyle(HSSFFont fontStyle, Short... alignment) { HSSFCellStyle style = wb1.createCellStyle(); style.setFont(fontStyle); if (alignment.length > 0) { style.setAlignment(alignment[0]); } return style; }
/** * Gets the new cell style. * * @return the new cell style */ public HSSFCellStyle getNewCellStyle() { return getWb() == null ? null : getWb().createCellStyle(); }
/** * Gets the new cell style. * * @return the new cell style */ public HSSFCellStyle getNewCellStyle() { return getWb() == null ? null : getWb().createCellStyle(); }
HSSFWorkbook wb = ...; DataFormat format = wb.createDataFormat(); HSSFCellStyle cellStyle = wb.createCellStyle(); style.setDataFormat(format.getFormat("@")); // or "text" cell.setCellStyle(cellStyle);
HSSFWorkbook wb = new HSSFWorkbook(); HSSFRow row = wb.createSheet().createRow(0); CellStyle cellStyle = wb.createCellStyle(); cellStyle.setDataFormat(wb.getCreationHelper().createDataFormat().getFormat("HH:mm:ss")); HSSFCell cell = row.createCell(1); Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 1970); cal.set(Calendar.MONTH, 0); cal.set(Calendar.DATE, 1); //you can set the time you need here ... cell.setCellValue(cal); cell.setCellStyle(cellStyle);
HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("Test"); Row row = sheet.createRow(0); CellStyle style = wb.createCellStyle(); style.setLocked(true); cell = row.createCell(0); cell.setCellStyle(style); // this is important as locking is pnly activated if sheet is protected sheet.protectSheet("");
protected void createCellStyle() { HSSFFont boldFont = wb.createFont(); boldFont.setBold(true); boldStyle = wb.createCellStyle(); boldStyle.setFont(boldFont); }
private static HSSFCellStyle createTextStyle(HSSFWorkbook wb) { HSSFFont plain = wb.createFont(); plain.setFontHeightInPoints((short)12); HSSFCellStyle textStyle = wb.createCellStyle(); textStyle.setFont(plain); return textStyle; }
protected void openWorkbook(OutputStream os) { workbook = new HSSFWorkbook(); emptyCellStyle = workbook.createCellStyle(); emptyCellStyle.setFillForegroundColor((new HSSFColor.WHITE()).getIndex()); emptyCellStyle.setFillPattern(backgroundMode); dataFormat = workbook.createDataFormat(); }
private HSSFCellStyle createStyle(final HSSFWorkbook workbook, boolean isFirst, short align) { HSSFCellStyle style = workbook.createCellStyle(); if (isFirst) { style.setBorderTop(HSSFCellStyle.BORDER_THIN); } if (align == RIGHT) { style.setAlignment(RIGHT); style.setDataFormat(dataFormat.getFormat("[HH]:MM:SS")); } return style; }
public static HSSFCellStyle rowStyle2(final HSSFSheet sheet) { HSSFCellStyle style = sheet.getWorkbook().createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM); style.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM); style.setBorderRight(HSSFCellStyle.BORDER_MEDIUM); style.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM); return style; } }
private static HSSFCellStyle createCommentStyle(HSSFWorkbook wb) { HSSFFont commentFont = wb.createFont(); commentFont.setColor(HSSFColor.GREEN.index); commentFont.setItalic(true); commentFont.setFontHeightInPoints((short)12); HSSFCellStyle commentStyle = wb.createCellStyle(); commentStyle.setFont(commentFont); return commentStyle; }
private HSSFCellStyle createHeaderStyle(){ //TO-DO read style information from sakai.properties HSSFFont font = gradesWorkbook.createFont(); font.setFontName(HSSFFont.FONT_ARIAL); font.setColor(IndexedColors.PLUM.getIndex()); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); HSSFCellStyle cellStyle = gradesWorkbook.createCellStyle(); cellStyle.setFont(font); return cellStyle; }
private void whiteDataStyle(HSSFSheet sheet) { HSSFCellStyle style = sheet.getWorkbook().createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); style.setWrapText(true); style.setFont(fontNormal); styles.put(I_WhiteDataStyle, style); }
CellStyle rowStyle=cell.getRow().getCustomCellStyle(); CellStyle colStyle=cell.getColumn().getCustomCellStyle(); HSSFCellStyle style=wb.createCellStyle(); style.setWrapText(true); String bgcolor=cellStyle.getBgcolor();
private static HSSFCellStyle createTilteStyle(HSSFWorkbook wb) { HSSFFont bold = wb.createFont(); bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); HSSFCellStyle style = wb.createCellStyle(); style.setFont(bold); style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setWrapText(true); return style; }