本文整理汇总了Java中org.apache.poi.xssf.usermodel.XSSFCellStyle.setLeftBorderColor方法的典型用法代码示例。如果您正苦于以下问题:Java XSSFCellStyle.setLeftBorderColor方法的具体用法?Java XSSFCellStyle.setLeftBorderColor怎么用?Java XSSFCellStyle.setLeftBorderColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.xssf.usermodel.XSSFCellStyle
的用法示例。
在下文中一共展示了XSSFCellStyle.setLeftBorderColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
/**
* @param color
* @param font
* @return CellStyle
*/
protected XSSFCellStyle getCellStyle(XSSFColor color, Font font) {
XSSFCellStyle style = wb.createCellStyle();
style.setFillForegroundColor(color);
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setWrapText(true); // new line
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderTop(CellStyle.BORDER_THIN);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
if(font != null) style.setFont(font);
return style;
}
示例2: updateSubreportBandElementStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
private XSSFCellStyle updateSubreportBandElementStyle(XSSFCellStyle 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;
}
示例3: setStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
public static XSSFCellStyle setStyle(XSSFWorkbook workbook) {
//设置字体;
XSSFFont font = workbook.createFont();
//设置字体大小;
font.setFontHeightInPoints((short) 20);
//设置字体名字;
font.setFontName("Courier New");
//font.setItalic(true);
//font.setStrikeout(true);
//设置样式;
XSSFCellStyle style = workbook.createCellStyle();
//设置底边框;
style.setBorderBottom(XSSFCellStyle.BORDER_THIN);
//设置底边框颜色;
style.setBottomBorderColor(new XSSFColor(Color.BLACK));
//设置左边框;
style.setBorderLeft(XSSFCellStyle.BORDER_THIN);
//设置左边框颜色;
style.setLeftBorderColor(new XSSFColor(Color.BLACK));
//设置右边框;
style.setBorderRight(XSSFCellStyle.BORDER_THIN);
//设置右边框颜色;
style.setRightBorderColor(new XSSFColor(Color.BLACK));
//设置顶边框;
style.setBorderTop(XSSFCellStyle.BORDER_THIN);
//设置顶边框颜色;
style.setTopBorderColor(new XSSFColor(Color.BLACK));
//在样式用应用设置的字体;
style.setFont(font);
//设置自动换行;
style.setWrapText(false);
//设置水平对齐的样式为居中对齐;
style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
//设置垂直对齐的样式为居中对齐;
style.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
return style;
}
示例4: getCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
protected XSSFCellStyle getCellStyle(int border, Font font) {
XSSFCellStyle style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setWrapText(true); // new line
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
if((border & BORDER_BOTTOM) > 0) style.setBorderBottom(CellStyle.BORDER_DOUBLE);
else style.setBorderBottom(CellStyle.BORDER_THIN);
if((border & BORDER_LEFT) > 0) style.setBorderLeft(CellStyle.BORDER_DOUBLE);
else style.setBorderLeft(CellStyle.BORDER_THIN);
if((border & BORDER_RIGHT) > 0) style.setBorderRight(CellStyle.BORDER_DOUBLE);
else style.setBorderRight(CellStyle.BORDER_THIN);
if((border & BORDER_TOP) > 0) style.setBorderTop(CellStyle.BORDER_DOUBLE);
else style.setBorderTop(CellStyle.BORDER_THIN);
if(font != null) style.setFont(font);
return style;
}
示例5: applyBorderStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的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 XSSFCellStyle ) {
XSSFCellStyle xStyle = (XSSFCellStyle)style;
BorderStyle xBorderStyle = poiBorderStyleFromBirt(borderStyleString, widthString);
XSSFColor xBorderColour = getXColour(colourString);
if(xBorderStyle != BorderStyle.NONE) {
switch( side ) {
case TOP:
xStyle.setBorderTop(xBorderStyle);
xStyle.setTopBorderColor(xBorderColour);
// log.debug( "Top border: " + xStyle.getBorderTop() + " / " + xStyle.getTopBorderXSSFColor().getARGBHex() );
break;
case LEFT:
xStyle.setBorderLeft(xBorderStyle);
xStyle.setLeftBorderColor(xBorderColour);
// log.debug( "Left border: " + xStyle.getBorderLeft() + " / " + xStyle.getLeftBorderXSSFColor().getARGBHex() );
break;
case RIGHT:
xStyle.setBorderRight(xBorderStyle);
xStyle.setRightBorderColor(xBorderColour);
// log.debug( "Right border: " + xStyle.getBorderRight() + " / " + xStyle.getRightBorderXSSFColor().getARGBHex() );
break;
case BOTTOM:
xStyle.setBorderBottom(xBorderStyle);
xStyle.setBottomBorderColor(xBorderColour);
// log.debug( "Bottom border: " + xStyle.getBorderBottom() + " / " + xStyle.getBottomBorderXSSFColor().getARGBHex() );
break;
}
}
}
}
}
示例6: createCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
/**
* Creates a new <code>CellStyle</code> for the given <code>Workbook</code>,
* with the given attributes. Moved from <code>StyleTag</code> here for
* 0.5.0.
* @param workbook A <code>Workbook</code>.
* @param alignment A <code>short</code> alignment constant.
* @param borderBottom A <code>short</code> border type constant.
* @param borderLeft A <code>short</code> border type constant.
* @param borderRight A <code>short</code> border type constant.
* @param borderTop A <code>short</code> border type constant.
* @param dataFormat A data format string.
* @param wrapText Whether text is wrapped.
* @param fillBackgroundColor A background <code>Color</code>.
* @param fillForegroundColor A foreground <code>Color</code>.
* @param fillPattern A <code>short</code> pattern constant.
* @param verticalAlignment A <code>short</code> vertical alignment constant.
* @param indention A <code>short</code> number of indent characters.
* @param rotationDegrees A <code>short</code> degrees rotation of text.
* @param bottomBorderColor A border <code>Color</code> object.
* @param leftBorderColor A border <code>Color</code> object.
* @param rightBorderColor A border <code>Color</code> object.
* @param topBorderColor A border <code>Color</code> object.
* @param locked Whether the cell is locked.
* @param hidden Whether the cell is hidden.
* @return A new <code>CellStyle</code>.
*/
public static CellStyle createCellStyle(Workbook workbook, short alignment, short borderBottom, short borderLeft,
short borderRight, short borderTop, String dataFormat, boolean wrapText, Color fillBackgroundColor,
Color fillForegroundColor, short fillPattern, short verticalAlignment, short indention,
short rotationDegrees, Color bottomBorderColor, Color leftBorderColor,
Color rightBorderColor, Color topBorderColor, boolean locked, boolean hidden)
{
CellStyle cs = workbook.createCellStyle();
cs.setAlignment(alignment);
cs.setBorderBottom(borderBottom);
cs.setBorderLeft(borderLeft);
cs.setBorderRight(borderRight);
cs.setBorderTop(borderTop);
cs.setDataFormat(workbook.getCreationHelper().createDataFormat().getFormat(dataFormat));
cs.setHidden(hidden);
cs.setIndention(indention);
cs.setLocked(locked);
cs.setRotation(rotationDegrees);
cs.setVerticalAlignment(verticalAlignment);
cs.setWrapText(wrapText);
// Certain properties need a type of workbook check.
if (workbook instanceof HSSFWorkbook)
{
if (bottomBorderColor != null)
cs.setBottomBorderColor(((HSSFColor) bottomBorderColor).getIndex());
if (leftBorderColor != null)
cs.setLeftBorderColor(((HSSFColor) leftBorderColor).getIndex());
if (rightBorderColor != null)
cs.setRightBorderColor(((HSSFColor) rightBorderColor).getIndex());
if (topBorderColor != null)
cs.setTopBorderColor(((HSSFColor) topBorderColor).getIndex());
// Per POI Javadocs, set foreground color first!
cs.setFillForegroundColor(((HSSFColor) fillForegroundColor).getIndex());
cs.setFillBackgroundColor(((HSSFColor) fillBackgroundColor).getIndex());
}
else
{
// XSSFWorkbook
XSSFCellStyle xcs = (XSSFCellStyle) cs;
if (bottomBorderColor != null)
xcs.setBottomBorderColor((XSSFColor) bottomBorderColor);
if (leftBorderColor != null)
xcs.setLeftBorderColor((XSSFColor) leftBorderColor);
if (rightBorderColor != null)
xcs.setRightBorderColor((XSSFColor) rightBorderColor);
if (topBorderColor != null)
xcs.setTopBorderColor((XSSFColor) topBorderColor);
// Per POI Javadocs, set foreground color first!
if (fillForegroundColor != null)
xcs.setFillForegroundColor((XSSFColor) fillForegroundColor);
if (fillBackgroundColor != null)
xcs.setFillBackgroundColor((XSSFColor) fillBackgroundColor);
}
cs.setFillPattern(fillPattern);
return cs;
}