List of usage examples for org.apache.poi.ss.usermodel CellStyle setBorderTop
void setBorderTop(BorderStyle border);
From source file:cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerBorderImpl.java
License:Apache License
@Override public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); style.setBorderLeft(BorderStyle.THIN); style.setBorderRight(BorderStyle.THIN); style.setBorderBottom(BorderStyle.THIN); style.setBorderTop(BorderStyle.THIN); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setDataFormat(STRING_FORMAT);/* w ww. j av a 2s .co m*/ if (isWarp) { style.setWrapText(true); } return style; }
From source file:cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerBorderImpl.java
License:Apache License
@Override public CellStyle getTitleStyle(short color) { CellStyle titleStyle = workbook.createCellStyle(); titleStyle.setBorderLeft(BorderStyle.THIN); titleStyle.setBorderRight(BorderStyle.THIN); titleStyle.setBorderBottom(BorderStyle.THIN); titleStyle.setBorderTop(BorderStyle.THIN); titleStyle.setAlignment(HorizontalAlignment.CENTER); titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); titleStyle.setWrapText(true);/*from ww w .java2 s. c om*/ return titleStyle; }
From source file:cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerColorImpl.java
License:Apache License
@Override public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); style.setBorderLeft(BorderStyle.THIN); style.setBorderRight(BorderStyle.THIN); style.setBorderBottom(BorderStyle.THIN); style.setBorderTop(BorderStyle.THIN); style.setFillForegroundColor((short) 41); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setDataFormat(STRING_FORMAT);/*from w w w . j a v a 2 s . co m*/ if (isWarp) { style.setWrapText(true); } return style; }
From source file:cn.bzvs.excel.export.styler.ExcelExportStylerBorderImpl.java
License:Apache License
@Override public CellStyle getHeaderStyle(short color) { CellStyle titleStyle = workbook.createCellStyle(); Font font = workbook.createFont(); font.setFontHeightInPoints((short) 12); titleStyle.setFont(font);//from www . j a va 2s .c o m titleStyle.setBorderLeft((short) 1); // titleStyle.setBorderRight((short) 1); // ? titleStyle.setBorderBottom((short) 1); titleStyle.setBorderTop((short) 1); titleStyle.setAlignment(CellStyle.ALIGN_CENTER); titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); return titleStyle; }
From source file:cn.bzvs.excel.export.styler.ExcelExportStylerBorderImpl.java
License:Apache License
@Override public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); style.setBorderLeft((short) 1); // style.setBorderRight((short) 1); // ? style.setBorderBottom((short) 1); style.setBorderTop((short) 1); style.setAlignment(CellStyle.ALIGN_CENTER); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setDataFormat(STRING_FORMAT);/*from w w w . ja v a2 s . c o m*/ if (isWarp) { style.setWrapText(true); } return style; }
From source file:cn.bzvs.excel.export.styler.ExcelExportStylerBorderImpl.java
License:Apache License
@Override public CellStyle getTitleStyle(short color) { CellStyle titleStyle = workbook.createCellStyle(); titleStyle.setBorderLeft((short) 1); // titleStyle.setBorderRight((short) 1); // ? titleStyle.setBorderBottom((short) 1); titleStyle.setBorderTop((short) 1); titleStyle.setAlignment(CellStyle.ALIGN_CENTER); titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); titleStyle.setWrapText(true);//w w w .ja v a 2s. c o m return titleStyle; }
From source file:cn.bzvs.excel.export.styler.ExcelExportStylerColorImpl.java
License:Apache License
@Override public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); style.setBorderLeft((short) 1); // style.setBorderRight((short) 1); // ? style.setBorderBottom((short) 1); style.setBorderTop((short) 1); style.setFillForegroundColor((short) 41); // style.setFillPattern(CellStyle.SOLID_FOREGROUND); // style.setAlignment(CellStyle.ALIGN_CENTER); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setDataFormat(STRING_FORMAT);/*from w ww. j a va2s. c o m*/ if (isWarp) { style.setWrapText(true); } return style; }
From source file:com.aan.girsang.client.ui.master.barang.BarangPanel.java
private void exportExcel(List<Barang> dataList) throws IOException { if (dataList != null && !dataList.isEmpty()) { HSSFWorkbook workBook = new HSSFWorkbook(); HSSFSheet sheet = workBook.createSheet(); HSSFSheet worksheet = workBook.createSheet("Sheet 0"); // Nama Field Row judul = sheet.createRow((short) 0); Cell cell = judul.createCell((short) 0); cell.setCellValue("This is a test of merging"); HSSFRow headingRow = sheet.createRow((short) 2); headingRow.createCell((short) 0).setCellValue("ID"); headingRow.createCell((short) 1).setCellValue("BARCODE 1"); headingRow.createCell((short) 2).setCellValue("BARCODE 2"); headingRow.createCell((short) 3).setCellValue("NAMA BARANG"); headingRow.createCell((short) 4).setCellValue("GOLONGAN"); headingRow.createCell((short) 5).setCellValue("SAT. JUAL"); headingRow.createCell((short) 6).setCellValue("ST. TOKO"); headingRow.createCell((short) 7).setCellValue("ST. GUDANG"); headingRow.createCell((short) 8).setCellValue("SAT. BELI"); headingRow.createCell((short) 9).setCellValue("ISI PEM."); headingRow.createCell((short) 10).setCellValue("HRG PEM."); headingRow.createCell((short) 11).setCellValue("HRG NORMAL"); headingRow.createCell((short) 12).setCellValue("HRG MEMBER"); headingRow.createCell((short) 13).setCellValue("JUAL"); int panjang = headingRow.getLastCellNum() - 1; short rowNo = 3; sheet.addMergedRegion(new CellRangeAddress(0, //first row (0-based) 0, //last row (0-based) 0, //first column (0-based) panjang //last column (0-based) ));// w ww . j a v a2 s .c om CellStyle styleData = workBook.createCellStyle(); styleData.setBorderBottom(CellStyle.BORDER_THIN); styleData.setBorderRight(CellStyle.BORDER_THIN); styleData.setBorderLeft(CellStyle.BORDER_THIN); for (Barang b : dataList) { HSSFRow row = sheet.createRow(rowNo); String jual; if (b.getJual() == true) { jual = "Jual"; } else { jual = "Tidak"; } row.createCell((short) 0).setCellValue(b.getPlu()); row.createCell((short) 1).setCellValue(b.getBarcode1()); row.createCell((short) 2).setCellValue(b.getBarcode2()); row.createCell((short) 3).setCellValue(b.getNamaBarang()); row.createCell((short) 4).setCellValue(b.getGolonganBarang().getGolonganBarang()); row.createCell((short) 5).setCellValue(b.getSatuan()); row.createCell((short) 6).setCellValue(b.getStokToko()); row.createCell((short) 7).setCellValue(b.getStokGudang()); row.createCell((short) 8).setCellValue(b.getSatuanPembelian()); row.createCell((short) 9).setCellValue(b.getIsiPembelian()); row.createCell((short) 10).setCellValue(TextComponentUtils.formatNumber(b.getHargaBeli())); row.createCell((short) 11).setCellValue(TextComponentUtils.formatNumber(b.getHargaNormal())); row.createCell((short) 12).setCellValue(TextComponentUtils.formatNumber(b.getHargaMember())); row.createCell((short) 13).setCellValue(jual); for (int i = 0; i <= 13; i++) { row.getCell((short) i).setCellStyle(styleData); } rowNo++; } for (int i = 0; i <= 13; i++) { sheet.autoSizeColumn(i); } Font font = workBook.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); //style judul CellStyle styleTitle = workBook.createCellStyle(); styleTitle.setAlignment(CellStyle.ALIGN_CENTER_SELECTION); styleTitle.setFont(font); judul.getCell(0).setCellStyle(styleTitle); //judul field CellStyle styleHeading = workBook.createCellStyle(); styleHeading.setFont(font); styleHeading.setAlignment(CellStyle.ALIGN_CENTER_SELECTION); styleHeading.setBorderBottom(CellStyle.BORDER_THIN); styleHeading.setBorderTop(CellStyle.BORDER_THIN); styleHeading.setBorderRight(CellStyle.BORDER_THIN); styleHeading.setBorderLeft(CellStyle.BORDER_THIN); for (int i = 0; i < headingRow.getLastCellNum(); i++) {//For each cell in the row headingRow.getCell(i).setCellStyle(styleHeading);//Set the style } String file = "D:/Student_detais.xls"; try { try (FileOutputStream fos = new FileOutputStream(file)) { workBook.write(fos); } JOptionPane.showMessageDialog(null, "Sukses"); } catch (FileNotFoundException e) { System.out.println("Invalid directory or file not found"); } catch (IOException e) { System.out.println("Error occurred while writting excel file to directory"); } } }
From source file:com.actelion.research.spiritapp.report.AbstractReport.java
License:Open Source License
private void initWorkbook() { wb = new XSSFWorkbook(); styles.clear();/*from w w w. j a va 2 s . com*/ styleWithBordersAbove.clear(); styleWithBordersUnder.clear(); CellStyle style; DataFormat df = wb.createDataFormat(); Font font = wb.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints((short) 14); style = wb.createCellStyle(); style.setFont(font); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TITLE14, style); font = wb.createFont(); font.setColor(IndexedColors.INDIGO.getIndex()); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints((short) 14); style = wb.createCellStyle(); style.setFont(font); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TITLE14BLUE, style); font = wb.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints((short) 12); style = wb.createCellStyle(); style.setFont(font); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TITLE12, style); font = wb.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints((short) 9); font = wb.createFont(); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_NONE); style.setBorderLeft(CellStyle.BORDER_NONE); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_PLAIN, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); font.setBoldweight(Font.BOLDWEIGHT_BOLD); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN); style.setTopBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TH_CENTER, style); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TH_LEFT, style); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TH_RIGHT, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_LEFT, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_RIGHT, style); font = wb.createFont(); font.setFontHeightInPoints((short) 8); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFont(font); style.setWrapText(true); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_SMALL, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setDataFormat(df.getFormat("0")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DOUBLE0, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.INDIGO.getIndex()); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_BLUE, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setDataFormat(df.getFormat("0.0")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DOUBLE1, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.INDIGO.getIndex()); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setDataFormat(df.getFormat("0.0")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DOUBLE1_BLUE, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.INDIGO.getIndex()); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setDataFormat(df.getFormat("0.00")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DOUBLE2_BLUE, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setDataFormat(df.getFormat("0.00")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DOUBLE2, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setDataFormat(df.getFormat("0.000")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DOUBLE3, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.MAROON.getIndex()); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setDataFormat(df.getFormat("0%")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DOUBLE100_RED, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.MAROON.getIndex()); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setDataFormat(df.getFormat("0.000")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DOUBLE3_RED, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.INDIGO.getIndex()); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setDataFormat(df.getFormat("0.000")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DOUBLE3_BLUE, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.MAROON.getIndex()); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_RED, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_CENTER, style); font = wb.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_BOLD_LEFT, style); font = wb.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_BOLD_CENTER, style); font = wb.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setFont(font); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_BOLD_RIGHT, style); font = wb.createFont(); font.setFontHeightInPoints((short) 9); style = wb.createCellStyle(); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setFont(font); style.setDataFormat(df.getFormat("d.mm.yyyy h:MM")); style.setWrapText(false); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styles.put(Style.S_TD_DATE, style); }
From source file:com.actelion.research.spiritapp.report.AbstractReport.java
License:Open Source License
protected void drawLineAbove(Sheet sheet, int row, int colMin, int colMax, short thickness) { Row r = sheet.getRow(row);/*from w w w . j a v a 2 s. c o m*/ if (r == null) r = sheet.createRow(row); for (int col = colMin; col <= colMax; col++) { Cell c = r.getCell(col); if (c == null) c = r.createCell(col); CellStyle style = styleWithBordersAbove.get(c.getCellStyle().getIndex() << 4 + thickness); if (style == null) { style = sheet.getWorkbook().createCellStyle(); style.cloneStyleFrom(c.getCellStyle()); style.setBorderTop(thickness); styleWithBordersAbove.put(c.getCellStyle().getIndex() << 4 + thickness, style); } c.setCellStyle(style); } }