• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Color类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getAttributeValue

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
protected final Object getAttributeValue(Column column, Cell cell, A source, String key) {
	Map<String, AttributeSupplier<A>> map = getAttributeSupplierMap();
	AttributeSupplier<A> supplier = map.get(key.toLowerCase());
	if (supplier == null) {
		throw new UnsupportedOperationException(MessageFormat.format(
				"unsupported attribute name={0}, choose in {1}", key, new TreeSet<>(map.keySet())));
	}
	Object value = supplier.get(column, cell, source);

	if (value instanceof Color) {
		int rgb = PoiExcelColorVisitor.getRGB((Color) value);
		if (rgb < 0) {
			return null;
		}
		if (column.getType() instanceof StringType) {
			value = String.format("%06x", rgb);
		} else {
			value = (long) rgb;
		}
	}
	return value;
}
 
开发者ID:hishidama,项目名称:embulk-parser-poi_excel,代码行数:23,代码来源:AbstractPoiExcelCellAttributeVisitor.java


示例2: styleColor

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
public void styleColor(Formatter out, String attr, Color color) {
    XSSFColor xSSFColor = (XSSFColor) color;
    if (color == null || xSSFColor.isAuto())
        return;

    byte[] rgb = xSSFColor.getRgb();
    if (rgb == null) {
        return;
    }
    out.format("  %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]);
}
 
开发者ID:xiaolanglang,项目名称:easypoi,代码行数:12,代码来源:StylerHelper.java


示例3: retrieveFont

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
/**
 * Retrieve a <code>Font</code> from the cache with the given
 * properties.
 * @param fontBoldweight The font boldweight.
 * @param fontItalic Whether the font is italic.
 * @param fontColor The font color.
 * @param fontName The font name.
 * @param fontHeightInPoints The font height in points.
 * @param fontUnderline The font underline.
 * @param fontStrikeout Whether the font is in strikeout.
 * @param fontCharset The font charset.
 * @param fontTypeOffset The font type offset.
 * @return A <code>Font</code> that matches all given properties, or
 *    <code>null</code> if it doesn't exist.
 */
public Font retrieveFont(short fontBoldweight, boolean fontItalic, Color fontColor, String fontName,
    short fontHeightInPoints, byte fontUnderline, boolean fontStrikeout, int fontCharset, short fontTypeOffset)
{
   String representation = getRepresentation(fontBoldweight, fontItalic, fontColor, fontName, fontHeightInPoints,
      fontUnderline, fontStrikeout, fontCharset, fontTypeOffset
   );
   Font f = myFontMap.get(representation);
   if (DEBUG)
   {
      if (f != null)
         System.err.println("FCache hit   : " + representation);
      else
         System.err.println("FCache miss! : " + representation);
   }
   return f;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:32,代码来源:FontCache.java


示例4: getRepresentation

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
/**
 * Gets the string representation of the given <code>Font</code>.
 * @param f A <code>Font</code>.
 * @return The string representation.
 */
private String getRepresentation(Font f)
{
   // Colors that need an instanceof check
   Color fontColor;
   if (f instanceof HSSFFont)
   {
      HSSFFont hf = (HSSFFont) f;
      fontColor = hf.getHSSFColor((HSSFWorkbook) myWorkbook);
   }
   else if (f instanceof XSSFFont)
   {
      XSSFFont xf = (XSSFFont) f;
      fontColor = xf.getXSSFColor();
   }
   else
      throw new IllegalArgumentException("Bad Font type: " + f.getClass().getName());

   return getRepresentation(f.getBoldweight(), f.getItalic(), fontColor, f.getFontName(),
      f.getFontHeightInPoints(), f.getUnderline(), f.getStrikeout(), f.getCharSet(), f.getTypeOffset());
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:26,代码来源:FontCache.java


示例5: getColorHexString

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
/**
 * Get the hex string that represents the <code>Color</code>.
 * @param color A POI <code>Color</code>.
 * @return The hex string that represents the <code>Color</code>.
 * @since 0.5.0
 */
public static String getColorHexString(Color color)
{
   if (color instanceof HSSFColor)
   {
      HSSFColor hssfColor = (HSSFColor) color;
      return getHSSFColorHexString(hssfColor);
   }
   else if (color == null)
   {
      return "null";
   }
   else
   {
      throw new IllegalArgumentException("Unexpected type of Color: " + color.getClass().getName());
   }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:23,代码来源:SheetUtil.java


示例6: createFont

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
/**
    * Creates a new <code>Font</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 fontBoldweight A <code>short</code> boldweight constant.
    * @param fontItalic Whether the text is italic.
    * @param fontColor A color <code>Color</code> opbject.
    * @param fontName A font name.
    * @param fontHeightInPoints A <code>short</code> font height in points.
    * @param fontUnderline A <code>byte</code> underline constant.
    * @param fontStrikeout Whether the font is strikeout.
    * @param fontCharset An <code>int</code> charset constant.
    * @param fontTypeOffset A <code>short</code> type offset constant.
    * @return A new <code>Font</code>.
    */
   public static Font createFont(Workbook workbook, short fontBoldweight, boolean fontItalic, Color fontColor, String fontName, short fontHeightInPoints, byte fontUnderline,
      boolean fontStrikeout, int fontCharset, short fontTypeOffset)
   {
      if (DEBUG)
      {
         System.err.println("createFont: " + fontBoldweight + "," + fontItalic + "," +
            ((fontColor == null) ? "null" :fontColor.toString()
//               (fontColor instanceof HSSFColor) ? fontColor.toString() :
//               ((XSSFColor) fontColor).getCTColor().toString()
            ) + "," + fontName + "," +
            fontHeightInPoints + "," + fontUnderline + "," + fontStrikeout + "," + fontCharset + "," + fontTypeOffset);
      }
      Font f = workbook.createFont();
      f.setBoldweight(fontBoldweight);
      f.setItalic(fontItalic);
      f.setFontName(fontName);
      f.setFontHeightInPoints(fontHeightInPoints);
      f.setUnderline(fontUnderline);
      f.setStrikeout(fontStrikeout);
      f.setCharSet(fontCharset);
      f.setTypeOffset(fontTypeOffset);
      // Color type check.
      if (fontColor instanceof HSSFColor)
      {
         f.setColor(((HSSFColor) fontColor).getIndex());
      }

      return f;
   }
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:46,代码来源:SheetUtil.java


示例7: getColor

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
private Color getColor(Font font) {
    if (helper instanceof HSSFHtmlHelper) {
        return ((HSSFWorkbook) sheet.getWorkbook()).getCustomPalette()
            .getColor(font.getColor());
    } else {
        return ((XSSFFont) font).getXSSFColor();
    }
}
 
开发者ID:rushingpig,项目名称:poix,代码行数:9,代码来源:StylerHelper.java


示例8: styleColor

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
public void styleColor(Formatter out, String attr, Color color) {
    if (color == null) {
        return;
    }
    HSSFColor hSSFColor = (HSSFColor) color;
    short[] rgb = hSSFColor.getTriplet();
    out.format("  %s: #%02x%02x%02x; %n", attr, rgb[0], rgb[1], rgb[2]);
}
 
开发者ID:rushingpig,项目名称:poix,代码行数:9,代码来源:StylerHelper.java


示例9: visitCellColor

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
public void visitCellColor(Column column, Color color, CellVisitor visitor) {
	int rgb = getRGB(color);
	if (rgb < 0) {
		PageBuilder pageBuilder = visitorValue.getPageBuilder();
		pageBuilder.setNull(column);
		return;
	}

	if (column.getType() instanceof StringType) {
		String s = String.format("%06x", rgb);
		visitor.visitCellValueString(column, color, s);
	} else {
		visitor.visitValueLong(column, color, rgb);
	}
}
 
开发者ID:hishidama,项目名称:embulk-parser-poi_excel,代码行数:16,代码来源:PoiExcelColorVisitor.java


示例10: getRGB

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
public static int getRGB(Color color) {
	if (color == null) {
		return -1;
	}

	int[] rgb = new int[3];
	if (color instanceof HSSFColor) {
		HSSFColor hssf = (HSSFColor) color;
		short[] s = hssf.getTriplet();
		rgb[0] = s[0] & 0xff;
		rgb[1] = s[1] & 0xff;
		rgb[2] = s[2] & 0xff;
	} else if (color instanceof XSSFColor) {
		XSSFColor xssf = (XSSFColor) color;
		byte[] b = xssf.getRGB();
		if (b == null) {
			return -1;
		}
		rgb[0] = b[0] & 0xff;
		rgb[1] = b[1] & 0xff;
		rgb[2] = b[2] & 0xff;
	} else {
		throw new IllegalStateException(MessageFormat.format("unsupported POI color={0}", color));
	}

	return (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
}
 
开发者ID:hishidama,项目名称:embulk-parser-poi_excel,代码行数:28,代码来源:PoiExcelColorVisitor.java


示例11: getHssfColor

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
public Color getHssfColor(short colorIndex) {
	HSSFWorkbook book = (HSSFWorkbook) visitorValue.getSheet().getWorkbook();
	return getHssfColor(book, colorIndex);
}
 
开发者ID:hishidama,项目名称:embulk-parser-poi_excel,代码行数:5,代码来源:PoiExcelColorVisitor.java


示例12: removeBorders

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
/**
 * Remove all borders from all cells in the region described by the left,
 * right, top, and bottom bounds.
 * @param sheet The <code>Sheet</code>.
 * @param left The 0-based index indicating the left-most part of the region.
 * @param right The 0-based index indicating the right-most part of the region.
 * @param top The 0-based index indicating the top-most part of the region.
 * @param bottom The 0-based index indicating the bottom-most part of the region.
 */
private void removeBorders(Sheet sheet, int left, int right, int top, int bottom)
{
   if (DEBUG)
      System.err.println("removeBorders: " + left + ", " + right + ", " + top + ", " + bottom);
   CellStyleCache csCache = getWorkbookContext().getCellStyleCache();
   for (int r = top; r <= bottom; r++)
   {
      Row row = sheet.getRow(r);
      for (int c = left; c <= right; c++)
      {
         Cell cell = row.getCell(c);
         if (cell != null)
         {
            CellStyle cs = cell.getCellStyle();
            Font f = sheet.getWorkbook().getFontAt(cs.getFontIndex());
            Color fontColor;
            if (cs instanceof HSSFCellStyle)
            {
               fontColor = ExcelColor.getHssfColorByIndex(f.getColor());
            }
            else
            {
               fontColor = ((XSSFFont) f).getXSSFColor();
            }
            // At this point, we have all of the desired CellStyle and Font
            // characteristics.  Find a CellStyle if it exists.
            CellStyle foundStyle = csCache.retrieveCellStyle(f.getBoldweight(), f.getItalic(), fontColor,
               f.getFontName(), f.getFontHeightInPoints(), cs.getAlignment(), CellStyle.BORDER_NONE,
               CellStyle.BORDER_NONE, CellStyle.BORDER_NONE, CellStyle.BORDER_NONE, cs.getDataFormatString(),
               f.getUnderline(), f.getStrikeout(), cs.getWrapText(), cs.getFillBackgroundColorColor(),
               cs.getFillForegroundColorColor(), cs.getFillPattern(), cs.getVerticalAlignment(), cs.getIndention(),
               cs.getRotation(), null, null, null, null,
               f.getCharSet(), f.getTypeOffset(), cs.getLocked(), cs.getHidden());

            if (foundStyle == null)
            {
               foundStyle = SheetUtil.createCellStyle(sheet.getWorkbook(), cs.getAlignment(), CellStyle.BORDER_NONE,
               CellStyle.BORDER_NONE, CellStyle.BORDER_NONE, CellStyle.BORDER_NONE, cs.getDataFormatString(),
                  cs.getWrapText(), cs.getFillBackgroundColorColor(), cs.getFillForegroundColorColor(),
                  cs.getFillPattern(), cs.getVerticalAlignment(), cs.getIndention(), cs.getRotation(),
                  null, null, null, null, cs.getLocked(), cs.getHidden());
               foundStyle.setFont(f);
            }
            cell.setCellStyle(foundStyle);
         }
      }
   }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:58,代码来源:SpanTag.java


示例13: putBackBorders

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
/**
 * Puts back borders for the newly sized merged region.
 * @param sheet The <code>Sheet</code>.
 * @param left The 0-based index indicating the left-most part of the region.
 * @param right The 0-based index indicating the right-most part of the region.
 * @param top The 0-based index indicating the top-most part of the region.
 * @param bottom The 0-based index indicating the bottom-most part of the region.
 * @param borderLeft The left border type.
 * @param borderRight The right border type.
 * @param borderTop The top border type.
 * @param borderBottom The bottom border type.
 * @param borderLeftColor The left border color.
 * @param borderRightColor The right border color.
 * @param borderTopColor The top border color.
 * @param borderBottomColor The bottom border color.
 */
private void putBackBorders(Sheet sheet, int left, int right, int top, int bottom,
   short borderLeft, short borderRight, short borderTop, short borderBottom,
   Color borderLeftColor, Color borderRightColor, Color borderTopColor, Color borderBottomColor)
{
   if (DEBUG)
      System.err.println("putBackBorders: " + left + ", " + right + ", " + top + ", " + bottom);
   CellStyleCache csCache = getWorkbookContext().getCellStyleCache();
   for (int r = top; r <= bottom; r++)
   {
      Row row = sheet.getRow(r);
      if (row == null)
         row = sheet.createRow(r);
      for (int c = left; c <= right; c++)
      {
         Cell cell = row.getCell(c);
         if (cell == null)
            cell = row.createCell(c);

         CellStyle cs = cell.getCellStyle();
         Font f = sheet.getWorkbook().getFontAt(cs.getFontIndex());
         Color fontColor;
         if (cs instanceof HSSFCellStyle)
         {
            fontColor = ExcelColor.getHssfColorByIndex(f.getColor());
         }
         else
         {
            fontColor = ((XSSFFont) f).getXSSFColor();
         }
         short newBorderBottom = (r == bottom) ? borderBottom : CellStyle.BORDER_NONE;
         short newBorderLeft = (c == left) ? borderLeft : CellStyle.BORDER_NONE;
         short newBorderRight = (c == right) ? borderRight : CellStyle.BORDER_NONE;
         short newBorderTop = (r == top) ? borderTop : CellStyle.BORDER_NONE;
         Color newBorderBottomColor = (r == bottom) ? borderBottomColor : null;
         Color newBorderLeftColor = (c == left) ? borderLeftColor : null;
         Color newBorderRightColor = (c == right) ? borderRightColor : null;
         Color newBorderTopColor = (r == top) ? borderTopColor : null;
         // At this point, we have all of the desired CellStyle and Font
         // characteristics.  Find a CellStyle if it exists.
         CellStyle foundStyle = csCache.retrieveCellStyle(f.getBoldweight(), f.getItalic(), fontColor,
            f.getFontName(), f.getFontHeightInPoints(), cs.getAlignment(),
            newBorderBottom, newBorderLeft, newBorderRight, newBorderTop, cs.getDataFormatString(),
            f.getUnderline(), f.getStrikeout(), cs.getWrapText(), cs.getFillBackgroundColorColor(),
            cs.getFillForegroundColorColor(), cs.getFillPattern(), cs.getVerticalAlignment(), cs.getIndention(),
            cs.getRotation(), newBorderBottomColor, newBorderLeftColor, newBorderRightColor, newBorderTopColor,
            f.getCharSet(), f.getTypeOffset(), cs.getLocked(), cs.getHidden());

         if (foundStyle == null)
         {
            foundStyle = SheetUtil.createCellStyle(sheet.getWorkbook(), cs.getAlignment(), newBorderBottom,
               newBorderLeft, newBorderRight, newBorderTop, cs.getDataFormatString(),
               cs.getWrapText(), cs.getFillBackgroundColorColor(), cs.getFillForegroundColorColor(),
               cs.getFillPattern(), cs.getVerticalAlignment(), cs.getIndention(), cs.getRotation(),
               newBorderBottomColor, newBorderLeftColor, newBorderRightColor, newBorderTopColor,
               cs.getLocked(), cs.getHidden());
            foundStyle.setFont(f);
         }
         cell.setCellStyle(foundStyle);
      }
   }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:78,代码来源:SpanTag.java


示例14: retrieveCellStyle

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
/**
 * Retrieve a <code>CellStyle</code> from the cache with the given
 * properties.
 * @param fontBoldweight The font boldweight.
 * @param fontItalic Whether the font is italic.
 * @param fontColor The font color.
 * @param fontName The font name.
 * @param fontHeightInPoints The font height in points.
 * @param alignment The horizontal alignment.
 * @param borderBottom The bottom border type.
 * @param borderLeft The left border type.
 * @param borderRight The right border type.
 * @param borderTop The top border type.
 * @param dataFormat The data format string.
 * @param fontUnderline The font underline.
 * @param fontStrikeout Whether the font is in strikeout.
 * @param wrapText Whether text is wrapped.
 * @param fillBackgroundColor The fill background color.
 * @param fillForegroundColor The fill foreground color.
 * @param fillPattern The fill pattern.
 * @param verticalAlignment The vertical alignment.
 * @param indention How many characters the text is indented.
 * @param rotation How many degrees the text is rotated.
 * @param bottomBorderColor The bottom border color.
 * @param leftBorderColor The left border color.
 * @param rightBorderColor The right border color.
 * @param topBorderColor The top border color.
 * @param fontCharset The font charset.
 * @param fontTypeOffset The font type offset.
 * @param locked Whether the cell is "locked".
 * @param hidden Whether the cell is "hidden".
 * @return A <code>CellStyle</code> that matches all given properties, or
 *    <code>null</code> if it doesn't exist.
 */
public CellStyle retrieveCellStyle(short fontBoldweight, boolean fontItalic, Color fontColor, String fontName,
    short fontHeightInPoints, short alignment, short borderBottom, short borderLeft, short borderRight,
    short borderTop, String dataFormat, byte fontUnderline, boolean fontStrikeout, boolean wrapText,
    Color fillBackgroundColor, Color fillForegroundColor, short fillPattern, short verticalAlignment,
    short indention, short rotation, Color bottomBorderColor, Color leftBorderColor, Color rightBorderColor,
    Color topBorderColor, int fontCharset, short fontTypeOffset, boolean locked, boolean hidden)
{
   String representation = getRepresentation(fontBoldweight, fontItalic, fontColor, fontName, fontHeightInPoints,
      alignment, borderBottom, borderLeft, borderRight, borderTop, dataFormat, fontUnderline, fontStrikeout,
      wrapText, fillBackgroundColor, fillForegroundColor, fillPattern, verticalAlignment, indention, rotation,
      bottomBorderColor, leftBorderColor, rightBorderColor, topBorderColor, fontCharset, fontTypeOffset, locked,
      hidden
   );
   CellStyle cs = myCellStyleMap.get(representation);
   if (DEBUG)
   {
      if (cs != null)
         System.err.println("CSCache hit  : " + representation);
      else
         System.err.println("CSCache miss!: " + representation);
   }
   return cs;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:58,代码来源:CellStyleCache.java


示例15: getRepresentation

import org.apache.poi.ss.usermodel.Color; //导入依赖的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());
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:49,代码来源:CellStyleCache.java


示例16: createCellStyle

import org.apache.poi.ss.usermodel.Color; //导入依赖的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;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:82,代码来源:SheetUtil.java


示例17: asColor

import org.apache.poi.ss.usermodel.Color; //导入依赖的package包/类
@Override
public java.awt.Color asColor() {
  return null;
}
 
开发者ID:uq-eresearch,项目名称:aorra,代码行数:5,代码来源:SpreadsheetDataSource.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VAlign类代码示例发布时间:2022-05-22
下一篇:
Java ObjectKey类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap