List of usage examples for org.apache.poi.ss.usermodel CellStyle setFillPattern
void setFillPattern(FillPatternType fp);
From source file:FormatConvert.tab2excel.java
public void tab2excel() throws FileNotFoundException, IOException { Workbook wb = new XSSFWorkbook(); Sheet sheet1 = wb.createSheet("input"); CellStyle style = wb.createCellStyle(); style.setFillForegroundColor(IndexedColors.ORANGE.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); int rowIndex = 0; BufferedReader br = null;/*from w w w .j a va 2 s . c o m*/ try { br = new BufferedReader(new FileReader(new File(input))); String[] str; while (br.ready()) { str = br.readLine().split(seperator); Row row = sheet1.createRow(rowIndex); for (int i = 0; i < str.length; i++) { row.createCell(i).setCellValue(str[i]); } rowIndex++; } br.close(); } catch (FileNotFoundException ex) { System.out.println(input + " is not found! please check your filepath "); } catch (IOException ex) { System.out.println("IO error"); } FileOutputStream fileOut = new FileOutputStream(output + ".xlsx"); wb.write(fileOut); fileOut.close(); System.out.println("Convert finished. The output file is named as " + output + ".xlsx"); }
From source file:FormatStatics.HeaderFormats.java
/** * A method to create a header style that is Grey in color and bold * @param wb The current workbook object * @return The desired cellstyle format/* w w w. j a va 2 s. c om*/ */ public static CellStyle GreyBoldCenterHeader(Workbook wb) { CellStyle style; Font headerFont = wb.createFont(); headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); style = BorderedStyle.createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(headerFont); return style; }
From source file:FormatStatics.HeaderFormats.java
/** * A generic method for creating a cell style with a gray bold header * @param wb The current workbook object * @return The desired cellstyle format// ww w . j a v a2 s. c om */ public static CellStyle GreyBoldHeader(Workbook wb) { CellStyle style; Font headerFont = wb.createFont(); headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); style = BorderedStyle.createBorderedStyle(wb); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(headerFont); return style; }
From source file:FormatStatics.HeaderFormats.java
/** * A generic method for creating a cell style with a gray header * @param wb The current workbook object * @return The desired cellstyle format//w ww . j a va 2 s. c o m */ public static CellStyle GreyHeader(Workbook wb) { CellStyle style; Font headerFont = wb.createFont(); style = BorderedStyle.createBorderedStyle(wb); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(headerFont); return style; }
From source file:FormatStatics.HeaderFormats.java
/** * A generic method for creating a cell style with a custom color bold header * @param wb The current workbook object * @param color a lowercase string indicating the color desired * @return The desired cellstyle format//from w w w .ja v a 2s. c o m */ public static CellStyle CustomBoldCenterHeader(Workbook wb, String color) { CellStyle style; Font headerFont = wb.createFont(); headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); style = BorderedStyle.createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFillForegroundColor(InterpretColor(color)); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(headerFont); return style; }
From source file:FormatStatics.HeaderFormats.java
/** * A generic method for creating a cell style with a custom bold header * @param wb The current workbook object * @param color a short value indicating the color desired; from the Apache * POI short list of colors/*from w w w .j a va2 s . c o m*/ * @return The desired cellstyle format */ public static CellStyle CustomBoldCenterHeader(Workbook wb, short color) { CellStyle style; Font headerFont = wb.createFont(); headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); style = BorderedStyle.createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFillForegroundColor(color); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(headerFont); return style; }
From source file:FormatStatics.HighlightStyle.java
/** * A Highlight style that uses a custom color short value; short values * are derived from the Apache POI color definitions * @param wb The current workbook object * @param color a short value indicating the color desired; from the Apache * POI short list of colors//w w w . ja v a 2 s . c om * @return The desired cellstyle format */ public static CellStyle CustomBoldHighlight(Workbook wb, Short color) { CellStyle style; Font highlightFont = wb.createFont(); highlightFont.setBoldweight(Font.BOLDWEIGHT_BOLD); style = BorderedStyle.createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFillForegroundColor(color); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(highlightFont); return style; }
From source file:FormatStatics.HighlightStyle.java
/** * A simple highlight style that returns a bright yellow highlight cell style * @param wb The current workbook object * @return The desired yellow cell style *///from w w w. j a v a 2 s. c o m public static CellStyle YellowBoldHighlight(Workbook wb) { CellStyle style; Font highlightFont = wb.createFont(); highlightFont.setBoldweight(Font.BOLDWEIGHT_BOLD); style = BorderedStyle.createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(highlightFont); return style; }
From source file:fr.amapj.service.engine.generator.excel.ExcelGeneratorTool.java
License:Open Source License
private void beWhite(CellStyle style) { style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.WHITE.getIndex()); }
From source file:fr.amapj.service.engine.generator.excel.ExcelGeneratorTool.java
License:Open Source License
private void beOrange(CellStyle style) { style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex()); }