本文整理汇总了Java中org.apache.poi.xssf.usermodel.XSSFCellStyle.getRightBorderXSSFColor方法的典型用法代码示例。如果您正苦于以下问题:Java XSSFCellStyle.getRightBorderXSSFColor方法的具体用法?Java XSSFCellStyle.getRightBorderXSSFColor怎么用?Java XSSFCellStyle.getRightBorderXSSFColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.xssf.usermodel.XSSFCellStyle
的用法示例。
在下文中一共展示了XSSFCellStyle.getRightBorderXSSFColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
private Style readStyle(XSSFCellStyle poiStyle) {
Style style = new Style();
XSSFColor poiBackgroundColor = poiStyle.getFillForegroundColorColor();
if (poiBackgroundColor != null) {
style.setBackgroundColor(readColor(poiBackgroundColor));
}
// 水平对齐类型
switch (poiStyle.getAlignment()) {
case org.apache.poi.ss.usermodel.CellStyle.ALIGN_LEFT: {
style.setHorizontalAlignment(TextAlignmentType.LEFT);
break;
}
case org.apache.poi.ss.usermodel.CellStyle.ALIGN_RIGHT: {
style.setHorizontalAlignment(TextAlignmentType.RIGHT);
break;
}
case org.apache.poi.ss.usermodel.CellStyle.ALIGN_GENERAL: {
style.setHorizontalAlignment(TextAlignmentType.GENERAL);
break;
}
default: {
style.setHorizontalAlignment(TextAlignmentType.CENTER);
}
}
// 垂直对齐类型
switch (poiStyle.getVerticalAlignment()) {
case org.apache.poi.ss.usermodel.CellStyle.VERTICAL_BOTTOM: {
style.setVerticalAlignment(TextAlignmentType.BOTTOM);
break;
}
case org.apache.poi.ss.usermodel.CellStyle.VERTICAL_TOP: {
style.setVerticalAlignment(TextAlignmentType.TOP);
break;
}
default: {
style.setVerticalAlignment(TextAlignmentType.CENTER);
}
}
// 边框类型
BorderCollection borderCollection = new BorderCollection();
style.setBorderCollection(borderCollection);
// 上边框
int borderType = poiStyle.getBorderTop();
XSSFColor borderColor = poiStyle.getTopBorderXSSFColor();
Border border = createBorder(borderType, borderColor);
borderCollection.setByBorderType(BorderType.TOP_BORDER, border);
// 下边框
borderType = poiStyle.getBorderBottom();
borderColor = poiStyle.getBottomBorderXSSFColor();
border = createBorder(borderType, borderColor);
borderCollection.setByBorderType(BorderType.BOTTOM_BORDER, border);
// 左边框
borderType = poiStyle.getBorderLeft();
borderColor = poiStyle.getLeftBorderXSSFColor();
border = createBorder(borderType, borderColor);
borderCollection.setByBorderType(BorderType.LEFT_BORDER, border);
// 右边框
borderType = poiStyle.getBorderRight();
borderColor = poiStyle.getRightBorderXSSFColor();
border = createBorder(borderType, borderColor);
borderCollection.setByBorderType(BorderType.RIGHT_BORDER, border);
// 字体
XSSFFont poiFont = poiStyle.getFont();
style.setFont(readFont(poiFont));
return style;
}
示例2: getRepresentation
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
/**
* Gets the string representation of the given <code>CellStyle</code>.
* @param cs A <code>CellStyle</code>.
* @return The string representation.
*/
private String getRepresentation(CellStyle cs)
{
Font f = myWorkbook.getFontAt(cs.getFontIndex());
// Colors that need an instanceof check
Color fontColor;
Color bottomColor = null;
Color leftColor = null;
Color rightColor = null;
Color topColor = null;
if (cs instanceof HSSFCellStyle)
{
HSSFFont hf = (HSSFFont) f;
fontColor = hf.getHSSFColor((HSSFWorkbook) myWorkbook);
// HSSF only stores border colors if the borders aren't "NONE".
if (cs.getBorderBottom() != CellStyle.BORDER_NONE)
bottomColor = ExcelColor.getHssfColorByIndex(cs.getBottomBorderColor());
if (cs.getBorderLeft() != CellStyle.BORDER_NONE)
leftColor = ExcelColor.getHssfColorByIndex(cs.getLeftBorderColor());
if (cs.getBorderRight() != CellStyle.BORDER_NONE)
rightColor = ExcelColor.getHssfColorByIndex(cs.getRightBorderColor());
if (cs.getBorderTop() != CellStyle.BORDER_NONE)
topColor = ExcelColor.getHssfColorByIndex(cs.getTopBorderColor());
}
else if (cs instanceof XSSFCellStyle)
{
XSSFFont xf = (XSSFFont) f;
fontColor = xf.getXSSFColor();
XSSFCellStyle xcs = (XSSFCellStyle) cs;
bottomColor = xcs.getBottomBorderXSSFColor();
leftColor = xcs.getLeftBorderXSSFColor();
rightColor = xcs.getRightBorderXSSFColor();
topColor = xcs.getTopBorderXSSFColor();
}
else
throw new IllegalArgumentException("Bad CellStyle type: " + cs.getClass().getName());
return getRepresentation(f.getBoldweight(), f.getItalic(), fontColor, f.getFontName(),
f.getFontHeightInPoints(), cs.getAlignment(), cs.getBorderBottom(), cs.getBorderLeft(), cs.getBorderRight(),
cs.getBorderTop(), cs.getDataFormatString(), f.getUnderline(), f.getStrikeout(), cs.getWrapText(),
cs.getFillBackgroundColorColor(), cs.getFillBackgroundColorColor(), cs.getFillPattern(), cs.getVerticalAlignment(),
cs.getIndention(), cs.getRotation(), bottomColor, leftColor, rightColor,
topColor, f.getCharSet(), f.getTypeOffset(), cs.getLocked(), cs.getHidden());
}