List of usage examples for org.apache.poi.xssf.usermodel XSSFCellStyle setRotation
@Override public void setRotation(short rotation)
Expressed in degrees.
From source file:coverageqc.functions.MyExcelEditor.java
public static void excelHeadingCreator(XSSFRow currentRow, String variantTsvHeadingLine) { XSSFCellStyle cellStyle = getDefaultCellStyle(currentRow); String[] headingsArray = variantTsvHeadingLine.split("\t"); for (int x = 0; x < headingsArray.length + 2; x++) { Cell cell = currentRow.createCell(x); // cell.setCellStyle(cellStyle); if (x == 0) { cell.setCellStyle(cellStyle); cell.setCellValue("Fellow's Interpretation"); } else if (x == 1) { cell.setCellStyle(cellStyle); cell.setCellValue("Attending Pathologist Interpretation"); } else {/* www . ja va 2 s . co m*/ if (headingsArray[x - 2].contains("Gene_") || headingsArray[x - 2].contains("Variant_") || headingsArray[x - 2].contains("Chr_") || headingsArray[x - 2].contains("Coordinate_") || headingsArray[x - 2].contains("Type_") || headingsArray[x - 2].contains("Genotype_") || headingsArray[x - 2].contains("Coordinate_") || headingsArray[x - 2].contains("Filters_")) { cellStyle = getDefaultCellStyle(currentRow); cellStyle.setRotation((short) 0); } else { cellStyle = getDefaultCellStyle(currentRow); cellStyle.setRotation((short) 90); } cell.setCellStyle(cellStyle); cell.setCellValue(headingsArray[x - 2]); } } //return currentRow; }
From source file:coverageqc.functions.MyExcelGenerator.java
public void excelHeadingCreator(String specifiedsheet, String headingLine) { XSSFSheet currentSheet = workbookcopy.createSheet(specifiedsheet); XSSFRow currentRow = currentSheet.createRow(0); XSSFCellStyle cellStyle; // String[] originalHeadingsArray = headingLine.split("\t"); this.originalHeadingsArray = headingLine.split("\t"); ;//from w w w. ja va 2s . c om HashMap<String, Integer> headings = new HashMap<String, Integer>(); for (int x = 0; x < originalHeadingsArray.length; x++) { headings.put(originalHeadingsArray[x].substring(0, originalHeadingsArray[x].indexOf("_")), x); } this.setRearrangedHashMap(headings); this.originalHeadings = headings; //the headers for the first three columns for (int x = 0; x < 3; x++) { Cell cell = currentRow.createCell(x); cellStyle = getDefaultCellStyle(currentRow, Color.WHITE); if (x == 0 || x == 1) { cell.setCellStyle(cellStyle); if (x == 0) { cell.setCellValue("Tom's Interpretation"); //cell.setCellValue("Fellow1's Interpretation"); } else { cell.setCellValue("Christina's Interpretation"); //cell.setCellValue("Fellow2's Interpretation"); } } else if (x == 2) { cell.setCellStyle(cellStyle); cell.setCellValue("Attending Pathologist Interpretation"); } } for (int x = 0; x < originalHeadingsArray.length; x++) { //plus three because have three header columns Cell cell = currentRow.createCell(x + 3); cellStyle = getDefaultCellStyle(currentRow, Color.WHITE); // cell.setCellStyle(cellStyle); if (this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)].contains("Gene_") || this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)].contains("Variant_") || this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)].contains("Chr_")) // ||originalHeadingsArray[x].contains("Coordinate_") // ||originalHeadingsArray[x].contains("Type_")) // ||originalHeadingsArray[x-3].contains("Genotype_") // ||originalHeadingsArray[x-3].contains("Coordinate_") // ||originalHeadingsArray[x-3].contains("Filters_")) { cellStyle.setRotation((short) 0); } else { cellStyle.setRotation((short) 90); } cell.setCellStyle(cellStyle); //cell.setCellValue(originalHeadingsArray[x-3]); // this.tsvRearrangeConversion.get(x) cell.setCellValue(this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)]); //cell.setCellValue(headinsArray[headingsConversion.get(x-3)]); } //end for loop //return currentRow; }
From source file:jdbreport.model.io.xls.poi.Excel2007Writer.java
License:Apache License
protected CellStyle createStyle(jdbreport.model.CellStyle style, Workbook wb) { XSSFCellStyle newStyle = (XSSFCellStyle) wb.createCellStyle(); newStyle.setAlignment(convertHorizontalAlign(style.getHorizontalAlignment())); newStyle.setVerticalAlignment(convertVerticalAlign(style.getVerticalAlignment())); Border border = style.getBorders(Border.LINE_BOTTOM); if (border != null) { newStyle.setBorderBottom(getBorder(border)); newStyle.setBottomBorderColor(new XSSFColor(border.getColor())); }/*from ww w. java 2s .c o m*/ border = style.getBorders(Border.LINE_TOP); if (border != null) { newStyle.setBorderTop(getBorder(border)); newStyle.setTopBorderColor(new XSSFColor(border.getColor())); } border = style.getBorders(Border.LINE_LEFT); if (border != null) { newStyle.setBorderLeft(getBorder(border)); newStyle.setLeftBorderColor(new XSSFColor(border.getColor())); } border = style.getBorders(Border.LINE_RIGHT); if (border != null) { newStyle.setBorderRight(getBorder(border)); newStyle.setRightBorderColor(new XSSFColor(border.getColor())); } Font font = wb.createFont(); font.setFontName(style.getFamily()); if (style.isBold()) { font.setBold(true); } font.setItalic(style.isItalic()); if (style.isUnderline()) { font.setUnderline(Font.U_SINGLE); } if (style.isStrikethrough()) { font.setStrikeout(true); } font.setFontHeightInPoints((short) style.getSize()); if (style.getForegroundColor() != null && !style.getForegroundColor().equals(Color.black)) { font.setColor(colorToIndex(wb, style.getForegroundColor())); } newStyle.setFont(font); if (style.getBackground() != null && !style.getBackground().equals(Color.white)) { newStyle.setFillForegroundColor(new XSSFColor(style.getBackground())); newStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); } if (style.getAngle() != 0) { int angle = style.getAngle(); if (angle > 90 && angle <= 180) { angle = 90; } else if (angle > 180 && angle <= 270) { angle = -90; } else if (angle > 270) { angle = -(360 - angle); } newStyle.setRotation((short) angle); } newStyle.setWrapText(style.isWrapLine()); return newStyle; }