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


Java HSSFCellStyle.setLeftBorderColor方法代码示例

本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFCellStyle.setLeftBorderColor方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFCellStyle.setLeftBorderColor方法的具体用法?Java HSSFCellStyle.setLeftBorderColor怎么用?Java HSSFCellStyle.setLeftBorderColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.hssf.usermodel.HSSFCellStyle的用法示例。


在下文中一共展示了HSSFCellStyle.setLeftBorderColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCellStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
/**
 * 获取单元格式样式
 *
 * @param wb
 * @param color
 * @return
 */
private static HSSFCellStyle getCellStyle(HSSFWorkbook wb, int color) {
    if (STYLE_MAP.get(color) != null) {
        return STYLE_MAP.get(color);
    }
    HSSFCellStyle style = wb.createCellStyle();
    if (color != -1) {
        style.setFillForegroundColor(Short.valueOf(color + ""));
        style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        style.setAlignment(CellStyle.ALIGN_CENTER);
    }
    style.setBorderBottom(CellStyle.BORDER_THIN);
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setBorderTop(CellStyle.BORDER_THIN);
    style.setBottomBorderColor(HSSFColor.BLACK.index);
    style.setLeftBorderColor(HSSFColor.BLACK.index);
    style.setRightBorderColor(HSSFColor.BLACK.index);
    style.setTopBorderColor(HSSFColor.BLACK.index);
    STYLE_MAP.put(color, style);
    return style;
}
 
开发者ID:ajtdnyy,项目名称:PackagePlugin,代码行数:29,代码来源:FileUtil.java

示例2: updateSubreportBandElementStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private HSSFCellStyle updateSubreportBandElementStyle(HSSFCellStyle cellStyle, BandElement bandElement, Object value, int gridRow, int gridColumn, int colSpan) {
	if (subreportCellStyle == null) {
		return cellStyle;
	}
	    	    	    	
	if (gridColumn == 0) {    		
		cellStyle.setBorderLeft(subreportCellStyle.getBorderLeft());    	
		cellStyle.setLeftBorderColor(subreportCellStyle.getLeftBorderColor());    	
	} else if (gridColumn+colSpan-1 == bean.getReportLayout().getColumnCount()-1) {    		
		cellStyle.setBorderRight(subreportCellStyle.getBorderRight());
		cellStyle.setRightBorderColor(subreportCellStyle.getRightBorderColor());
	}     	    	
	
	if (pageRow == 0) {    		    		
		cellStyle.setBorderTop(subreportCellStyle.getBorderTop());  
		cellStyle.setTopBorderColor(subreportCellStyle.getTopBorderColor());  
	} else if ( (pageRow+1) == getRowsCount()) {    	    		
		cellStyle.setBorderBottom(subreportCellStyle.getBorderBottom());    	
		cellStyle.setBottomBorderColor(subreportCellStyle.getBottomBorderColor());
	}    	
	    
	return cellStyle;
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:24,代码来源:XlsExporter.java

示例3: copyCellStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
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;
    }
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:30,代码来源:POIUtils.java

示例4: copyCellStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
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;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:31,代码来源:POIUtils.java

示例5: applyBorderStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
@Override
public void applyBorderStyle(Workbook workbook, CellStyle style, BorderSide side, CSSValue colour, CSSValue borderStyle, CSSValue width) {
	if( ( colour != null ) || ( borderStyle != null ) || ( width != null ) ) {
		String colourString = colour == null ? "rgb(0,0,0)" : colour.getCssText();
		String borderStyleString = borderStyle == null ? "solid" : borderStyle.getCssText();
		String widthString = width == null ? "medium" : width.getCssText();

		if( style instanceof HSSFCellStyle ) {
			HSSFCellStyle hStyle = (HSSFCellStyle)style;
			
			short hBorderStyle = poiBorderStyleFromBirt(borderStyleString, widthString);
			short colourIndex = getHColour((HSSFWorkbook)workbook, colourString);
			if( colourIndex > 0 ) {
				if(hBorderStyle != CellStyle.BORDER_NONE) {
					switch( side ) {
					case TOP:
						hStyle.setBorderTop(hBorderStyle);
						hStyle.setTopBorderColor(colourIndex);
						// log.debug( "Top border: " + xStyle.getBorderTop() + " / " + xStyle.getTopBorderXSSFColor().getARGBHex() );
						break;
					case LEFT:
						hStyle.setBorderLeft(hBorderStyle);
						hStyle.setLeftBorderColor(colourIndex);
						// log.debug( "Left border: " + xStyle.getBorderLeft() + " / " + xStyle.getLeftBorderXSSFColor().getARGBHex() );
						break;
					case RIGHT:
						hStyle.setBorderRight(hBorderStyle);
						hStyle.setRightBorderColor(colourIndex);
						// log.debug( "Right border: " + xStyle.getBorderRight() + " / " + xStyle.getRightBorderXSSFColor().getARGBHex() );
						break;
					case BOTTOM:
						hStyle.setBorderBottom(hBorderStyle);
						hStyle.setBottomBorderColor(colourIndex);
						// log.debug( "Bottom border: " + xStyle.getBorderBottom() + " / " + xStyle.getBottomBorderXSSFColor().getARGBHex() );
						break;
					}
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:42,代码来源:StyleManagerHUtils.java

示例6: main

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {

           HSSFWorkbook wb = new HSSFWorkbook();
  
           HSSFSheet sheet = wb.createSheet("Planilha");

           HSSFRow row = sheet.createRow((short) 2);
           
           HSSFCell cell = row.createCell((short) (1),HSSFCell.CELL_TYPE_STRING);


           cell.setCellValue("Alinhe isto!fim");
           
           sheet.setColumnWidth( (short) 1, (short) ( ( 10 * cell.getStringCellValue().length() ) / ( (double) 1 / 20 ) ) );
           
           

           HSSFCellStyle estilo = wb.createCellStyle();

          

           //Alinhando ao centro

           estilo.setAlignment(HSSFCellStyle.ALIGN_CENTER);

          
           short cor = HSSFColor.BLUE.index;

           // inserindo fontes e cores.
           estilo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
           estilo.setFillForegroundColor(HSSFColor.GREEN.index);
            //estilo.setFillBackgroundColor(HSSFColor.BLUE.index);
           // estilo.setFillForegroundColor(HSSFColor.BLUE.index2);

           // funcionando
//           estilo.setFillPattern(HSSFCellStyle.FINE_DOTS );
//           estilo.setFillBackgroundColor(new HSSFColor.RED().getIndex()); 

//           estilo.setFillPattern(HSSFCellStyle.FINE_DOTS );
//           estilo.setFillForegroundColor(new HSSFColor.BLUE().getIndex());
//           estilo.setFillBackgroundColor(new HSSFColor.RED().getIndex()); 
          
//           estilo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//           estilo.setFillForegroundColor(new HSSFColor.RED().getIndex());

           
           
           //Adicionando bordas
           estilo.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);

           estilo.setBottomBorderColor(cor);

           estilo.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);

           estilo.setLeftBorderColor(cor);

           estilo.setBorderRight(HSSFCellStyle.BORDER_THIN);

           estilo.setRightBorderColor(cor);

           estilo.setBorderTop(HSSFCellStyle.BORDER_MEDIUM_DASHED);

           estilo.setTopBorderColor(cor);


           cell.setCellStyle(estilo);

           FileOutputStream fileOut = new FileOutputStream("C:/planilha.xls");

           wb.write(fileOut);

           fileOut.close();





    }
 
开发者ID:darciopacifico,项目名称:omr,代码行数:79,代码来源:PoiTest.java


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