当前位置: 首页>>代码示例>>Java>>正文


Java IndexedColors类代码示例

本文整理汇总了Java中org.apache.poi.ss.usermodel.IndexedColors的典型用法代码示例。如果您正苦于以下问题:Java IndexedColors类的具体用法?Java IndexedColors怎么用?Java IndexedColors使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IndexedColors类属于org.apache.poi.ss.usermodel包,在下文中一共展示了IndexedColors类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: defaultDataCellStyle

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
/**
 * Returns the default data cell style. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultDataCellStyle(final Workbook wb) {
    CellStyle style;
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setWrapText(true);
    style.setBorderRight(BorderStyle.THIN);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(BorderStyle.THIN);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderTop(BorderStyle.THIN);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderBottom(BorderStyle.THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setDataFormat(doubleDataFormat);
    return style;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:25,代码来源:ExcelExport.java

示例2: defaultHeaderCellStyle

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
/**
 * Returns the default header style. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultHeaderCellStyle(final Workbook wb) {
    CellStyle style;
    final Font monthFont = wb.createFont();
    monthFont.setFontHeightInPoints((short) 11);
    monthFont.setColor(IndexedColors.WHITE.getIndex());
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFont(monthFont);
    style.setWrapText(true);
    return style;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:23,代码来源:ExcelExport.java

示例3: createStyles

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
/**
     * 创建表格样式
     * @param wb 工作薄对象
     * @return 样式列表
     */
    private Map<String, CellStyle> createStyles(Workbook wb) {
        Map<String, CellStyle> styles = new HashMap<String, CellStyle>();

        CellStyle style = wb.createCellStyle();
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        Font titleFont = wb.createFont();
        titleFont.setFontName("Arial");
        titleFont.setFontHeightInPoints((short) 16);
        titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        style.setFont(titleFont);
        styles.put("title", style);

        style = wb.createCellStyle();
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        Font dataFont = wb.createFont();
        dataFont.setFontName("Arial");
        dataFont.setFontHeightInPoints((short) 10);
        style.setFont(dataFont);
        styles.put("data", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(CellStyle.ALIGN_LEFT);
        styles.put("data1", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(CellStyle.ALIGN_CENTER);
        styles.put("data2", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        styles.put("data3", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
//		style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        Font headerFont = wb.createFont();
        headerFont.setFontName("Arial");
        headerFont.setFontHeightInPoints((short) 10);
        headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        headerFont.setColor(IndexedColors.WHITE.getIndex());
        style.setFont(headerFont);
        styles.put("header", style);

        return styles;
    }
 
开发者ID:sombie007,项目名称:ExcelHandle,代码行数:66,代码来源:ExportExcel.java

示例4: createHeadStyle

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
CellStyle createHeadStyle() {
	if (headerCellStyle != null) {
		return headerCellStyle;
	}
	CellStyle style = wb.createCellStyle();
	// 设置这些样式
	style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
	style.setFillPattern(CellStyle.SOLID_FOREGROUND);

	style.setAlignment(CellStyle.ALIGN_CENTER);
	// 生成一个字体
	Font font = wb.createFont();
	font.setColor(IndexedColors.BLACK.index);
	font.setFontHeightInPoints((short) 12);
	font.setBoldweight(Font.BOLDWEIGHT_BOLD);
	// 把字体应用到当前的样式
	style.setFont(font);
	headerCellStyle = style;
	return style;
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:21,代码来源:AbstractWriteHandler.java

示例5: createHeadDateStyle

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
CellStyle createHeadDateStyle() {
	if (headDateCellStyle != null) {
		return headDateCellStyle;
	}
	CellStyle cellStyle = wb.createCellStyle();
	DataFormat format = wb.createDataFormat();
	cellStyle.setDataFormat(format.getFormat("m/d/yy h:mm"));

	// 设置这些样式
	cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
	cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

	cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
	// 生成一个字体
	Font font = wb.createFont();
	font.setColor(IndexedColors.BLACK.index);
	font.setFontHeightInPoints((short) 12);
	font.setBoldweight(Font.BOLDWEIGHT_BOLD);
	// 把字体应用到当前的样式
	cellStyle.setFont(font);

	headDateCellStyle = cellStyle;
	return cellStyle;
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:25,代码来源:AbstractWriteHandler.java

示例6: createLinkStyle

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
private CellStyle createLinkStyle(boolean bordered) {
	final Font hlinkFont = wb.createFont();
	hlinkFont.setUnderline(Font.U_SINGLE);
	hlinkFont.setColor(IndexedColors.BLUE.getIndex());
	
	final CellStyle style;
	if (bordered) {
		style = createBorderedStyle(wb);
	} else {
		style = wb.createCellStyle();
	}
	
	style.setFont(hlinkFont);
	style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
	style.setIndention((short) 1);
	style.setWrapText(true);
	
	return style;
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:20,代码来源:ExcelUtils.java

示例7: createBorderedStyle

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
private static CellStyle createBorderedStyle(Workbook wb) {
    CellStyle 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());
    return style;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:13,代码来源:Exporter.java

示例8: formatCellStatus

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
protected void formatCellStatus(Sheet sheet, Cell cell) {
	cell.setCellStyle(styles.get("status"));
	SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
	ConditionalFormattingRule ruleGreen = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "1");
	PatternFormatting fill1 = ruleGreen.createPatternFormatting();
	fill1.setFillBackgroundColor(IndexedColors.GREEN.index);
	fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	ConditionalFormattingRule ruleRed = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "0");
	PatternFormatting fill2 = ruleRed.createPatternFormatting();
	fill2.setFillBackgroundColor(IndexedColors.RED.index);
	fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	ConditionalFormattingRule ruleOrange = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "2");
	PatternFormatting fill3 = ruleOrange.createPatternFormatting();
	fill3.setFillBackgroundColor(IndexedColors.ORANGE.index);
	fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	String name = CellReference.convertNumToColString(cell.getColumnIndex());
	String location = "$" + name + "$" + cell.getRowIndex() + ":$" + name + "$" + (cell.getRowIndex() + 1);

	CellRangeAddress[] regions = { CellRangeAddress.valueOf(location) };
	ConditionalFormattingRule[] cfRules = new ConditionalFormattingRule[] { ruleGreen, ruleRed, ruleOrange };
	sheetCF.addConditionalFormatting(regions, cfRules);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:26,代码来源:XLTest.java

示例9: createStyles

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
/**
 * excel 样式
 *
 * @return
 */
public Map<String, CellStyle> createStyles(Workbook workbook) {
    Map<String, CellStyle> styles = new HashMap();
    CellStyle style = workbook.createCellStyle();
    style.setAlignment((short) 2);
    style.setVerticalAlignment((short) 1);
    Font titleFont = workbook.createFont();
    titleFont.setFontName("Arial");
    titleFont.setFontHeightInPoints((short) 16);
    titleFont.setBoldweight((short) 700);
    style.setFont(titleFont);
    styles.put("title", style);
    style = workbook.createCellStyle();
    style.setVerticalAlignment((short) 1);
    style.setBorderRight((short) 1);
    style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderLeft((short) 1);
    style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderTop((short) 1);
    style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderBottom((short) 1);
    style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    Font dataFont = workbook.createFont();
    dataFont.setFontName("Arial");
    dataFont.setFontHeightInPoints((short) 10);
    style.setFont(dataFont);
    styles.put("data", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 1);
    styles.put("data1", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 2);
    styles.put("data2", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 3);
    styles.put("data3", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 2);
    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern((short) 1);
    Font headerFont = workbook.createFont();
    headerFont.setFontName("Arial");
    headerFont.setFontHeightInPoints((short) 10);
    headerFont.setBoldweight((short) 700);
    headerFont.setColor(IndexedColors.WHITE.getIndex());
    style.setFont(headerFont);
    styles.put("header", style);
    return styles;
}
 
开发者ID:zhangbiy,项目名称:exportExcel,代码行数:58,代码来源:ExcelTest.java

示例10: createBorderCellStyle

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
public CellStyle createBorderCellStyle(Workbook workbook, boolean showBorder) {
	CellStyle style = workbook.createCellStyle();
	if (showBorder) {
		style.setBorderRight(BorderStyle.THIN);
		style.setRightBorderColor(IndexedColors.BLACK.getIndex());
		style.setBorderBottom(BorderStyle.THIN);
		style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
		style.setBorderLeft(BorderStyle.THIN);
		style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
		style.setBorderTop(BorderStyle.THIN);
		style.setTopBorderColor(IndexedColors.BLACK.getIndex());
	}
	return style;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:15,代码来源:AbstractStyleBuilder.java

示例11: crateCaptionCellStyle

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
/**
 * 
 * @return
 */
protected CellStyle crateCaptionCellStyle() {
	Font font = workbook.createFont();
	font.setColor(Font.COLOR_NORMAL);
	CellStyle cellStyle = workbook.createCellStyle();
	cellStyle.setWrapText(false);
	font.setFontHeight((short) 250);
	cellStyle.setFont(font);
	cellStyle.setFillForegroundColor(IndexedColors.BLUE_GREY.index);
	cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
	cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
	return cellStyle;
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:17,代码来源:AbstractPoiExcelTemplate.java

示例12: setBold

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
/**
 * Set a bold font for the given cell with a given font size (in pt).
 * 
 * @param wb
 *            the workbook that contains the cell
 * @param cell
 *            the cell where the text is contained
 * @param size
 *            the size in pt of the text
 */
public static void setBold(Workbook wb, HSSFCell cell, short size) {
	Font font = wb.createFont();
	font.setFontHeightInPoints((short) size);
	font.setFontName("Arial");
	font.setColor(IndexedColors.BLACK.getIndex());
	font.setBold(true);
	font.setItalic(false);

	CellStyle style = wb.createCellStyle();
	style.setFont(font);
	cell.setCellStyle(style);
}
 
开发者ID:turnus,项目名称:turnus,代码行数:23,代码来源:PoiUtils.java

示例13: setLink

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
/**
 * Set a link to a cell. The link type should one of {@link Hyperlink}
 * 
 * @param wb
 *            the workbook which contains the cell
 * @param cell
 *            the cell where the link is stored
 * @param address
 *            the cell destination address
 * @param linkType
 *            the type selected among {@link Hyperlink}
 */
public static void setLink(Workbook wb, HSSFCell cell, String address, int linkType) {
	CreationHelper helper = wb.getCreationHelper();
	CellStyle style = wb.createCellStyle();
	Font font = wb.createFont();
	font.setUnderline(Font.U_SINGLE);
	font.setColor(IndexedColors.BLUE.getIndex());
	style.setFont(font);

	Hyperlink link = helper.createHyperlink(linkType);
	link.setAddress(address);
	cell.setHyperlink(link);
	cell.setCellStyle(style);
}
 
开发者ID:turnus,项目名称:turnus,代码行数:26,代码来源:PoiUtils.java

示例14: test2

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
@Test
public void test2() throws IOException{
	 Workbook wb = new HSSFWorkbook();
	    Sheet sheet = wb.createSheet("new sheet");

	    // Create a row and put some cells in it. Rows are 0 based.
	    Row row = sheet.createRow(1);

	    // Create a cell and put a value in it.
	    

	    // Style the cell with borders all around.
	    CellStyle style = wb.createCellStyle();
	    
	    //     style.setFillBackgroundColor(IndexedColors.AUTOMATIC.getIndex());
	   style.setFillPattern(CellStyle.SOLID_FOREGROUND);
	   style.setFillForegroundColor(IndexedColors.LIGHT_ORANGE.index);
	   
	    Font font = wb.createFont();
	    font.setFontHeightInPoints((short)24);
	    font.setFontName("Courier New");
	    font.setItalic(true);
	    font.setStrikeout(true);
	    style.setFont(font);
	    CellUtil.createCell(row, 1, "nihao",style);
	    //style.setFont(font);
	    // Write the output to a file
	    FileOutputStream fileOut = new FileOutputStream("workbook.xls");
	    wb.write(fileOut);
	    fileOut.close();
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:32,代码来源:MyTest.java

示例15: createTitle

import org.apache.poi.ss.usermodel.IndexedColors; //导入依赖的package包/类
protected void createTitle() {
	short lineThickness = (short) (6 * BASE_HEIGHT);
	
	// Top Line
	Row row = sheet.createRow(ROW_4);
	row.setHeight(lineThickness);
	
	XSSFCellStyle style = wb.createCellStyle();
	style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
	style.setFillPattern(CellStyle.SOLID_FOREGROUND);
	setDummyTitleStyle(row,style);
	
	// Title
	row = sheet.createRow(ROW_5);
	row.setHeightInPoints(100);
	sheet.addMergedRegion(CellRangeAddress.valueOf("B5:G5"));
	
	Font font = wb.createFont();
	font.setFontHeightInPoints((short)28);
	font.setFontName("Trebuchet MS");
	font.setBoldweight(Font.BOLDWEIGHT_BOLD);
	style = wb.createCellStyle();
	style.setFont(font);
	style.setAlignment(CellStyle.ALIGN_CENTER);
	style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

	setDummyTitleStyle(row,style);
	row.getCell(COL_B).setCellValue("Open Source License Verification Report");
	
	// Bottom Line
	row = sheet.createRow(ROW_6);
	row.setHeight(lineThickness);
	
	style = wb.createCellStyle();
	style.setFillForegroundColor(DARK_BLUE);
	style.setFillPattern(CellStyle.SOLID_FOREGROUND);
	setDummyTitleStyle(row,style);
}
 
开发者ID:spdx,项目名称:ATTIC-osit,代码行数:39,代码来源:CoverSheetTemplate.java


注:本文中的org.apache.poi.ss.usermodel.IndexedColors类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。