org.apache.poi.hssf.usermodel.HSSFFont Java Examples
The following examples show how to use
org.apache.poi.hssf.usermodel.HSSFFont.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UKExcelUtil.java From youkefu with Apache License 2.0 | 8 votes |
@SuppressWarnings("deprecation") private CellStyle baseCellStyle(){ CellStyle cellStyle = wb.createCellStyle(); cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); cellStyle.setWrapText(true); cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); Font font = wb.createFont(); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); font.setFontName("宋体"); font.setFontHeight((short) 200); cellStyle.setFont(font); return cellStyle; }
Example #2
Source File: ExcelExporterProcess.java From youkefu with Apache License 2.0 | 8 votes |
private CellStyle baseCellStyle(){ CellStyle cellStyle = wb.createCellStyle(); cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); cellStyle.setWrapText(true); cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); Font font = wb.createFont(); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); //font.setFontName("宋体"); font.setFontHeight((short) 200); cellStyle.setFont(font); return cellStyle; }
Example #3
Source File: POIUtils.java From ermasterr with Apache License 2.0 | 7 votes |
public static HSSFCellStyle copyCellStyle(final HSSFWorkbook workbook, final HSSFCellStyle style) { final HSSFCellStyle newCellStyle = workbook.createCellStyle(); newCellStyle.setAlignment(style.getAlignment()); newCellStyle.setBorderBottom(style.getBorderBottom()); newCellStyle.setBorderLeft(style.getBorderLeft()); newCellStyle.setBorderRight(style.getBorderRight()); newCellStyle.setBorderTop(style.getBorderTop()); newCellStyle.setBottomBorderColor(style.getBottomBorderColor()); newCellStyle.setDataFormat(style.getDataFormat()); newCellStyle.setFillBackgroundColor(style.getFillBackgroundColor()); newCellStyle.setFillForegroundColor(style.getFillForegroundColor()); newCellStyle.setFillPattern(style.getFillPattern()); newCellStyle.setHidden(style.getHidden()); newCellStyle.setIndention(style.getIndention()); newCellStyle.setLeftBorderColor(style.getLeftBorderColor()); newCellStyle.setLocked(style.getLocked()); newCellStyle.setRightBorderColor(style.getRightBorderColor()); newCellStyle.setRotation(style.getRotation()); newCellStyle.setTopBorderColor(style.getTopBorderColor()); newCellStyle.setVerticalAlignment(style.getVerticalAlignment()); newCellStyle.setWrapText(style.getWrapText()); final HSSFFont font = workbook.getFontAt(style.getFontIndex()); newCellStyle.setFont(font); return newCellStyle; }
Example #4
Source File: ExcelAutoColumnSizer.java From cuba with Apache License 2.0 | 6 votes |
public void notifyCellValue(String val, HSSFFont font) { if (val == null || val.length() == 0) return; if (font == null) throw new IllegalArgumentException("font is null"); short width; { FontMetrics fm = getFontMetrics(font); int w = fm.stringWidth(val); width = (w > Short.MAX_VALUE) ? Short.MAX_VALUE : (short) w; // TODO - this gives an underestimate with large font-sizes. // TODO - What we *should* be considering is the 'display width'. // This means we'd have to take into account cell type & format. } if (width > currentWidth) { currentWidth = width; } }
Example #5
Source File: POIUtils.java From ermaster-b with Apache License 2.0 | 6 votes |
public static HSSFFont copyFont(HSSFWorkbook workbook, HSSFFont font) { HSSFFont newFont = workbook.createFont(); // newFont.setBoldweight(font.getBoldweight()); // newFont.setCharSet(font.getCharSet()); // newFont.setColor(font.getColor()); // newFont.setFontHeight(font.getFontHeight()); // newFont.setFontHeightInPoints(font.getFontHeightInPoints()); // newFont.setFontName(font.getFontName()); // newFont.setItalic(font.getItalic()); // newFont.setStrikeout(font.getStrikeout()); // newFont.setTypeOffset(font.getTypeOffset()); // newFont.setUnderline(font.getUnderline()); return newFont; }
Example #6
Source File: Prd5391IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testFastExport() throws ResourceException, ReportProcessingException, IOException { // This establishes a baseline for the second test using the slow export. final MasterReport report = DebugReportRunner.parseLocalReport( "Prd-5391.prpt", Prd5391IT.class ); final ByteArrayOutputStream bout = new ByteArrayOutputStream(); FastExcelReportUtil.processXls( report, bout ); final HSSFWorkbook wb = new HSSFWorkbook( new ByteArrayInputStream( bout.toByteArray() ) ); final HSSFSheet sheetAt = wb.getSheetAt( 0 ); final HSSFRow row = sheetAt.getRow( 0 ); final HSSFCell cell0 = row.getCell( 0 ); // assert that we are in the correct export type .. final HSSFCellStyle cellStyle = cell0.getCellStyle(); final HSSFColor fillBackgroundColorColor = cellStyle.getFillBackgroundColorColor(); final HSSFColor fillForegroundColorColor = cellStyle.getFillForegroundColorColor(); Assert.assertEquals( "0:0:0", fillBackgroundColorColor.getHexString() ); Assert.assertEquals( "FFFF:8080:8080", fillForegroundColorColor.getHexString() ); HSSFFont font = cellStyle.getFont( wb ); Assert.assertEquals( "Times New Roman", font.getFontName() ); }
Example #7
Source File: Prd5391IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testSlowExport() throws ResourceException, ReportProcessingException, IOException { // This establishes a baseline for the second test using the slow export. final MasterReport report = DebugReportRunner.parseLocalReport( "Prd-5391.prpt", Prd5391IT.class ); final ByteArrayOutputStream bout = new ByteArrayOutputStream(); ExcelReportUtil.createXLS( report, bout ); final HSSFWorkbook wb = new HSSFWorkbook( new ByteArrayInputStream( bout.toByteArray() ) ); final HSSFSheet sheetAt = wb.getSheetAt( 0 ); final HSSFRow row = sheetAt.getRow( 0 ); final HSSFCell cell0 = row.getCell( 0 ); // assert that we are in the correct export type .. final HSSFCellStyle cellStyle = cell0.getCellStyle(); final HSSFColor fillBackgroundColorColor = cellStyle.getFillBackgroundColorColor(); final HSSFColor fillForegroundColorColor = cellStyle.getFillForegroundColorColor(); Assert.assertEquals( "0:0:0", fillBackgroundColorColor.getHexString() ); Assert.assertEquals( "FFFF:8080:8080", fillForegroundColorColor.getHexString() ); HSSFFont font = cellStyle.getFont( wb ); Assert.assertEquals( "Times New Roman", font.getFontName() ); }
Example #8
Source File: HSSFFontWrapper.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates a HSSFFontWrapper for the excel font. * * @param font * the font. */ public HSSFFontWrapper( final Font font ) { if ( font == null ) { throw new NullPointerException( "Font is null" ); } if ( font.getColor() < 0 ) { throw new IllegalArgumentException( "Negative color index is not allowed" ); } fontName = normalizeFontName( font.getFontName() ); fontHeight = font.getFontHeightInPoints(); bold = font.getBold(); italic = font.getItalic(); underline = ( font.getUnderline() != HSSFFont.U_NONE ); strikethrough = font.getStrikeout(); colorIndex = font.getColor(); }
Example #9
Source File: HSSFFontCacheKey.java From yarg with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object obj) { if (obj instanceof HSSFFontCacheKey) { HSSFFontCacheKey objKey = (HSSFFontCacheKey) obj; HSSFFont objFont = objKey.font; if (font == objFont) { return true; } if (objFont == null) { return false; } if (fontRecord == null) { if (objKey.fontRecord != null) { return false; } } else if (!fontRecord.equals(objKey.fontRecord)) { return false; } return true; } else { return false; } }
Example #10
Source File: StyleManagerHUtils.java From birt with Eclipse Public License 1.0 | 6 votes |
@Override public void addColourToFont(Workbook workbook, Font font, String colour) { if(colour == null) { return ; } if(IStyle.TRANSPARENT_VALUE.equals(colour)) { return ; } if(font instanceof HSSFFont) { HSSFFont hFont = (HSSFFont)font; short colourIndex = getHColour((HSSFWorkbook)workbook, colour); if( colourIndex > 0 ) { hFont.setColor(colourIndex); } } }
Example #11
Source File: TestExportExcel.java From poi with Apache License 2.0 | 6 votes |
@Test public void exportExcelWithStyle() { try { String filePath = TestUtil.DOC_PATH + File.separator + Globals.EXPORT_PRODUCT; OutputStream os = new FileOutputStream(filePath); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(Globals.SHEETNAME); HSSFRichTextString richString = new HSSFRichTextString( TestUtil.RICH_TEXT_STRING); HSSFFont font = wb.createFont(); font.setColor(IndexedColors.BLUE.index); richString.applyFont(font); sheet.createRow(0).createCell(0).setCellValue(richString); wb.write(os); os.close(); } catch (Exception e) { e.printStackTrace(); } }
Example #12
Source File: POIUtils.java From ermasterr with Apache License 2.0 | 6 votes |
public static HSSFFont copyFont(final HSSFWorkbook workbook, final HSSFFont font) { final HSSFFont newFont = workbook.createFont(); // newFont.setBoldweight(font.getBoldweight()); // newFont.setCharSet(font.getCharSet()); // newFont.setColor(font.getColor()); // newFont.setFontHeight(font.getFontHeight()); // newFont.setFontHeightInPoints(font.getFontHeightInPoints()); // newFont.setFontName(font.getFontName()); // newFont.setItalic(font.getItalic()); // newFont.setStrikeout(font.getStrikeout()); // newFont.setTypeOffset(font.getTypeOffset()); // newFont.setUnderline(font.getUnderline()); return newFont; }
Example #13
Source File: JRXlsMetadataExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
protected HSSFRichTextString getRichTextString(JRStyledText styledText, short forecolor, JRFont defaultFont, Locale locale) { String text = styledText.getText(); HSSFRichTextString richTextStr = new HSSFRichTextString(text); int runLimit = 0; AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator(); while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) { Map<Attribute,Object> attributes = iterator.getAttributes(); JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes); short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null ? getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex() : forecolor; HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale); richTextStr.applyFont(iterator.getIndex(), runLimit, font); iterator.setIndex(runLimit); } return richTextStr; }
Example #14
Source File: JRXlsExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
public StyleInfo( FillPatternType mode, short backcolor, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, short rotation, HSSFFont font, JRExporterGridCell gridCell, boolean wrapText, boolean cellLocked, boolean cellHidden, boolean shrinkToFit ) { this(mode, backcolor, horizontalAlignment, verticalAlignment, rotation, font, (gridCell == null ? null : new BoxStyle(gridCell)), wrapText, cellLocked, cellHidden, shrinkToFit); }
Example #15
Source File: JRXlsExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
protected HSSFCellStyle getLoadedCellStyle( FillPatternType mode, short backcolor, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, short rotation, HSSFFont font, BoxStyle box, boolean isWrapText, boolean isCellLocked, boolean isCellHidden, boolean isShrinkToFit ) { StyleInfo style = new StyleInfo(mode, backcolor, horizontalAlignment, verticalAlignment, rotation, font, box, isWrapText, isCellLocked, isCellHidden, isShrinkToFit); return getLoadedCellStyle(style); }
Example #16
Source File: ExportExcelUtils.java From dk-fitting with Apache License 2.0 | 6 votes |
private static CellStyle createHeaderStyle(Workbook workbook){ // 生成一个样式 CellStyle style = workbook.createCellStyle(); // 设置表头的样式 style.setFillForegroundColor(HSSFColor.WHITE.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 生成表头的字体 Font font = workbook.createFont(); font.setColor(HSSFColor.VIOLET.index); font.setFontHeightInPoints((short) 12); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 把字体应用到当前的样式 style.setFont(font); return style; }
Example #17
Source File: JRXlsExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
protected HSSFRichTextString getRichTextString(JRStyledText styledText, short forecolor, JRFont defaultFont, Locale locale) { String text = styledText.getText(); HSSFRichTextString richTextStr = new HSSFRichTextString(text); int runLimit = 0; AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator(); while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) { Map<Attribute,Object> attributes = iterator.getAttributes(); JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes); short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null ? getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex() : forecolor; HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale); richTextStr.applyFont(iterator.getIndex(), runLimit, font); iterator.setIndex(runLimit); } return richTextStr; }
Example #18
Source File: TitleStyleBuilder.java From bdf3 with Apache License 2.0 | 6 votes |
private HSSFCellStyle createHSSFCellStyle(Workbook wb, int[] bgColor, int[] fontColor, int fontSize) { HSSFWorkbook workbook = (HSSFWorkbook) wb; HSSFPalette palette = workbook.getCustomPalette(); palette.setColorAtIndex((short) 9, (byte) fontColor[0], (byte) fontColor[1], (byte) fontColor[2]); palette.setColorAtIndex((short) 10, (byte) bgColor[0], (byte) bgColor[1], (byte) bgColor[2]); HSSFFont titleFont = workbook.createFont(); titleFont.setCharSet(HSSFFont.DEFAULT_CHARSET); titleFont.setFontName("宋体"); titleFont.setColor((short) 9); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); titleFont.setFontHeightInPoints((short) fontSize); HSSFCellStyle titleStyle = (HSSFCellStyle) createBorderCellStyle(workbook, true); titleStyle.setFont(titleFont); titleStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); titleStyle.setFillForegroundColor((short) 10); titleStyle.setAlignment(CellStyle.ALIGN_CENTER); titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); return titleStyle; }
Example #19
Source File: JRXlsExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
public StyleInfo( FillPatternType mode, short backcolor, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, short rotation, HSSFFont font, BoxStyle box, boolean wrapText, boolean cellLocked, boolean cellHidden, boolean shrinkToFit ) { this.mode = mode; this.backcolor = backcolor; this.horizontalAlignment = horizontalAlignment; this.verticalAlignment = verticalAlignment; this.rotation = rotation; this.font = font; this.box = box; this.lcWrapText = shrinkToFit ? false : wrapText; this.lcCellLocked = cellLocked; this.lcCellHidden = cellHidden; this.lcShrinkToFit = shrinkToFit; hashCode = computeHash(); }
Example #20
Source File: POIUtils.java From ermaster-b with Apache License 2.0 | 5 votes |
public static HSSFCellStyle copyCellStyle(HSSFWorkbook workbook, HSSFCellStyle style) { HSSFCellStyle newCellStyle = workbook.createCellStyle(); newCellStyle.setAlignment(style.getAlignment()); newCellStyle.setBorderBottom(style.getBorderBottom()); newCellStyle.setBorderLeft(style.getBorderLeft()); newCellStyle.setBorderRight(style.getBorderRight()); newCellStyle.setBorderTop(style.getBorderTop()); newCellStyle.setBottomBorderColor(style.getBottomBorderColor()); newCellStyle.setDataFormat(style.getDataFormat()); newCellStyle.setFillBackgroundColor(style.getFillBackgroundColor()); newCellStyle.setFillForegroundColor(style.getFillForegroundColor()); newCellStyle.setFillPattern(style.getFillPattern()); newCellStyle.setHidden(style.getHidden()); newCellStyle.setIndention(style.getIndention()); newCellStyle.setLeftBorderColor(style.getLeftBorderColor()); newCellStyle.setLocked(style.getLocked()); newCellStyle.setRightBorderColor(style.getRightBorderColor()); newCellStyle.setRotation(style.getRotation()); newCellStyle.setTopBorderColor(style.getTopBorderColor()); newCellStyle.setVerticalAlignment(style.getVerticalAlignment()); newCellStyle.setWrapText(style.getWrapText()); HSSFFont font = workbook.getFontAt(style.getFontIndex()); newCellStyle.setFont(font); return newCellStyle; }
Example #21
Source File: ColorUtils.java From Octopus with MIT License | 5 votes |
public static void setColor(Workbook workbook, Font font, Color color) { if (color == null) { return; } if (font instanceof XSSFFont) { ((XSSFFont) font).setColor(new XSSFColor(color)); } else if (font instanceof HSSFFont && workbook instanceof HSSFWorkbook) { font.setColor(getSimilarColor((HSSFWorkbook) workbook, color).getIndex()); } else { log.error("unknown font type"); } }
Example #22
Source File: HSSFFontCacheKey.java From yarg with Apache License 2.0 | 5 votes |
public HSSFFontCacheKey(HSSFFont font) { this.font = font; if (font != null) { this.fontRecord = XslStyleHelper.getFieldValue(font, "font"); } else { this.fontRecord = null; } }
Example #23
Source File: XslStyleHelper.java From yarg with Apache License 2.0 | 5 votes |
public static void cloneFont(HSSFCellStyle source, HSSFCellStyle target) { // Handle matching things if we cross workbooks InternalWorkbook sourceWorkbook = getWorkbookFromStyle(source); InternalWorkbook targetWorkbook = getWorkbookFromStyle(target); if (targetWorkbook != sourceWorkbook) { // Finally we need to clone the font, and update the format record for this FontRecord fr = targetWorkbook.createNewFont(); fr.cloneStyleFrom(sourceWorkbook.getFontRecordAt(source.getFontIndex())); HSSFFont font = newInstance(HSSFFont.class, new Class[]{int.class, FontRecord.class}, (short)targetWorkbook.getFontIndex(fr), fr); target.setFont(font); } }
Example #24
Source File: TitleStyleBuilder.java From bdf3 with Apache License 2.0 | 5 votes |
private XSSFCellStyle createXSSFCellStyle(Workbook wb, int[] bgColor, int[] fontColor, int fontSize) { SXSSFWorkbook workbook = (SXSSFWorkbook) wb; XSSFFont titleFont = (XSSFFont) workbook.createFont(); titleFont.setCharSet(HSSFFont.DEFAULT_CHARSET); titleFont.setFontName("宋体"); XSSFColor color9 = new XSSFColor(new java.awt.Color(fontColor[0], fontColor[1], fontColor[2])); XSSFColor color10 = new XSSFColor(new java.awt.Color(bgColor[0], bgColor[1], bgColor[2])); if (!(fontColor[0] == 0 && fontColor[1] == 0 && fontColor[2] == 0)) { titleFont.setColor(color9); } titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); titleFont.setFontHeightInPoints((short) fontSize); XSSFCellStyle titleStyle = (XSSFCellStyle) createBorderCellStyle(workbook, true); titleStyle.setFont(titleFont); titleStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); titleStyle.setFillForegroundColor(color10); titleStyle.setAlignment(CellStyle.ALIGN_CENTER); titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); return titleStyle; }
Example #25
Source File: SpreadsheetExporter.java From sakai with Educational Community License v2.0 | 5 votes |
private CellStyle createHeaderStyle(){ //TO-DO read style information from sakai.properties Font font = gradesWorkbook.createFont(); font.setFontName(HSSFFont.FONT_ARIAL); font.setColor(IndexedColors.PLUM.getIndex()); font.setBold(true); CellStyle cellStyle = gradesWorkbook.createCellStyle(); cellStyle.setFont(font); return cellStyle; }
Example #26
Source File: TransactionSummaryController.java From primefaces-blueprints with The Unlicense | 5 votes |
public void postProcessXLS(Object document) { HSSFWorkbook wb = (HSSFWorkbook) document; HSSFSheet sheet = wb.getSheetAt(0); HSSFRow header = sheet.getRow(0); HSSFCellStyle cellStyle = wb.createCellStyle(); cellStyle.setFillForegroundColor(HSSFColor.GREEN.index); cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); for (int i = 0; i < header.getPhysicalNumberOfCells(); i++) { HSSFCell cell = header.getCell(i); cell.setCellStyle(cellStyle); } Row row = sheet.createRow((short) sheet.getLastRowNum() + 3); Cell cellDisclaimer = row.createCell(0); HSSFFont customFont = wb.createFont(); customFont.setFontHeightInPoints((short) 10); customFont.setFontName("Arial"); customFont.setColor(IndexedColors.BLACK.getIndex()); customFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); customFont.setItalic(true); cellDisclaimer.setCellValue("Disclaimer"); HSSFCellStyle cellStyleDisclaimer = wb.createCellStyle(); cellStyleDisclaimer.setFont(customFont); cellDisclaimer.setCellStyle(cellStyleDisclaimer); Row row1 = sheet.createRow(sheet.getLastRowNum() + 2); Cell cellDisclaimerContent1 = row1.createCell(0); cellDisclaimerContent1 .setCellValue("The information contained in this website is for information purposes only, and does not constitute, nor is it intended to constitute, the provision of financial product advice."); Row row2 = sheet.createRow(sheet.getLastRowNum() + 1); Cell cellDisclaimerContent2 = row2.createCell(0); cellDisclaimerContent2 .setCellValue("This website is intended to track the investor account summary information,investments and transaction in a partcular period of time. "); }
Example #27
Source File: AccountSummaryController.java From primefaces-blueprints with The Unlicense | 5 votes |
public void postProcessXLS(Object document) { HSSFWorkbook wb = (HSSFWorkbook) document; HSSFSheet sheet = wb.getSheetAt(0); HSSFRow header = sheet.getRow(0); HSSFCellStyle cellStyle = wb.createCellStyle(); cellStyle.setFillForegroundColor(HSSFColor.GREEN.index); cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); for(int i=0; i < header.getPhysicalNumberOfCells();i++) { HSSFCell cell = header.getCell(i); cell.setCellStyle(cellStyle); } Row row=sheet.createRow((short)sheet.getLastRowNum()+3); Cell cellDisclaimer = row.createCell(0); HSSFFont customFont= wb.createFont(); customFont.setFontHeightInPoints((short)10); customFont.setFontName("Arial"); customFont.setColor(IndexedColors.BLACK.getIndex()); customFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); customFont.setItalic(true); cellDisclaimer.setCellValue("Disclaimer"); HSSFCellStyle cellStyleDisclaimer = wb.createCellStyle(); cellStyleDisclaimer.setFont(customFont); cellDisclaimer.setCellStyle(cellStyleDisclaimer); Row row1=sheet.createRow(sheet.getLastRowNum()+2); Cell cellDisclaimerContent1 = row1.createCell(0); cellDisclaimerContent1.setCellValue("The information contained in this website is for information purposes only, and does not constitute, nor is it intended to constitute, the provision of financial product advice."); Row row2=sheet.createRow(sheet.getLastRowNum()+1); Cell cellDisclaimerContent2 = row2.createCell(0); cellDisclaimerContent2.setCellValue("This website is intended to track the investor account summary information,investments and transaction in a partcular period of time. "); }
Example #28
Source File: InvestmentSummaryController.java From primefaces-blueprints with The Unlicense | 5 votes |
public void postProcessXLS(Object document) { HSSFWorkbook wb = (HSSFWorkbook) document; HSSFSheet sheet = wb.getSheetAt(0); HSSFRow header = sheet.getRow(0); HSSFCellStyle cellStyle = wb.createCellStyle(); cellStyle.setFillForegroundColor(HSSFColor.GREEN.index); cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); for(int i=0; i < header.getPhysicalNumberOfCells();i++) { HSSFCell cell = header.getCell(i); cell.setCellStyle(cellStyle); } Row row=sheet.createRow((short)sheet.getLastRowNum()+3); Cell cellDisclaimer = row.createCell(0); HSSFFont customFont= wb.createFont(); customFont.setFontHeightInPoints((short)10); customFont.setFontName("Arial"); customFont.setColor(IndexedColors.BLACK.getIndex()); customFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); customFont.setItalic(true); cellDisclaimer.setCellValue("Disclaimer"); HSSFCellStyle cellStyleDisclaimer = wb.createCellStyle(); cellStyleDisclaimer.setFont(customFont); cellDisclaimer.setCellStyle(cellStyleDisclaimer); Row row1=sheet.createRow(sheet.getLastRowNum()+2); Cell cellDisclaimerContent1 = row1.createCell(0); cellDisclaimerContent1.setCellValue("The information contained in this website is for information purposes only, and does not constitute, nor is it intended to constitute, the provision of financial product advice."); Row row2=sheet.createRow(sheet.getLastRowNum()+1); Cell cellDisclaimerContent2 = row2.createCell(0); cellDisclaimerContent2.setCellValue("This website is intended to track the investor account summary information,investments and transaction in a partcular period of time. "); }
Example #29
Source File: ExportUtil.java From jumbune with GNU Lesser General Public License v3.0 | 5 votes |
/** * Sets header style * @param worksheet the worksheet * @param fontName font name * @param fontColor font color * @param fontBoldweight font weight */ public static void setHeaderStyle(Worksheet worksheet, String fontName, short fontColor, short fontBoldweight) { HSSFWorkbook workbook = worksheet.getWorkbook(); HSSFFont font = workbook.createFont(); font.setFontName(fontName); font.setColor(fontColor); font.setBoldweight(fontBoldweight); HSSFCellStyle cellStyle = workbook.createCellStyle(); cellStyle.setFont(font); worksheet.setCellStyle(cellStyle); }
Example #30
Source File: JRXlsMetadataExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
protected HSSFCellStyle getLoadedCellStyle( FillPatternType mode, short backcolor, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, short rotation, HSSFFont font, BoxStyle box, boolean isCellLocked, boolean isCellHidden, boolean isShrinkToFit ) { return getLoadedCellStyle(new StyleInfo(mode, backcolor, horizontalAlignment, verticalAlignment, rotation, font, box, true, isCellLocked, isCellHidden, isShrinkToFit)); }