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

Java Colour类代码示例

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

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



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

示例1: format

import jxl.format.Colour; //导入依赖的package包/类
/**
 * 单元格的格式设置 字体大小 颜色 对齐方式、背景颜色等...
 */
public static void format() {
    try {
        arial14font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD);
        arial14font.setColour(jxl.format.Colour.LIGHT_BLUE);
        arial14format = new WritableCellFormat(arial14font);
        arial14format.setAlignment(jxl.format.Alignment.CENTRE);
        arial14format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
        arial14format.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);

        arial10font = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);
        arial10format = new WritableCellFormat(arial10font);
        arial10format.setAlignment(jxl.format.Alignment.CENTRE);
        arial10format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
        arial10format.setBackground(Colour.GRAY_25);

        arial12font = new WritableFont(WritableFont.ARIAL, 10);
        arial12format = new WritableCellFormat(arial12font);
        arial10format.setAlignment(jxl.format.Alignment.CENTRE);//对齐格式
        arial12format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); //设置边框

    } catch (WriteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:HowieTianDev,项目名称:ChenYan,代码行数:28,代码来源:ExcelUtils.java


示例2: getHeader

import jxl.format.Colour; //导入依赖的package包/类
public static WritableCellFormat getHeader() {
	WritableFont font = new WritableFont(WritableFont.TIMES, 10,
			WritableFont.BOLD);// 定义字体
	try {
		font.setColour(Colour.BLUE);// 蓝色字体
	} catch (WriteException e1) {
		e1.printStackTrace();
	}
	WritableCellFormat format = new WritableCellFormat(font);
	try {
		format.setAlignment(jxl.format.Alignment.CENTRE);// 左右居中
		format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);// 上下居中
		// format.setBorder(Border.ALL, BorderLineStyle.THIN,
		// Colour.BLACK);// 黑色边框
		// format.setBackground(Colour.YELLOW);// 黄色背景
	} catch (WriteException e) {
		e.printStackTrace();
	}
	return format;
}
 
开发者ID:reallin,项目名称:Android_Excel,代码行数:21,代码来源:ExcelUtil.java


示例3: ExcelWriter

import jxl.format.Colour; //导入依赖的package包/类
/**
 * ExcelWriter constructor. 
 * @param outputFile Excel 2003 output workbook.
 * @throws IOException Unable to work with output location.
 */
public ExcelWriter(File outputFile) throws IOException
{
    workbook = Workbook.createWorkbook(outputFile);
    WritableFont font1 = new WritableFont(WritableFont.ARIAL, 10); 
    WritableFont font2= new WritableFont(WritableFont.ARIAL, 10);
    WritableFont font3= new WritableFont(WritableFont.ARIAL, 10);
    WritableFont defaultFont= new WritableFont(WritableFont.ARIAL, 10);
    try {
        font1.setColour(Colour.DARK_BLUE);
        font1.setBoldStyle(WritableFont.BOLD);
        font2.setBoldStyle(WritableFont.BOLD);
        font2.setColour(Colour.RED);
        font3.setColour(Colour.BLACK);
        font3.setBoldStyle(WritableFont.BOLD);
        } 
    catch (WriteException ex) 
    {
     
    }
    
    BoldBlue= new WritableCellFormat(font1);
    BoldRed= new WritableCellFormat(font2);
    BoldBlack= new WritableCellFormat(font3);
    Default= new WritableCellFormat(defaultFont);
}
 
开发者ID:kbakhit,项目名称:RuleSet_Library,代码行数:31,代码来源:ExcelWriter.java


示例4: annotateCellWithError

import jxl.format.Colour; //导入依赖的package包/类
private void annotateCellWithError(jxl.Cell parsedCell, jxl.write.WritableSheet annotatedErrorSheet, WorkbookParseError error) throws WriteException
  {
    Label errorLabel = new Label(parsedCell.getColumn(),
                                 parsedCell.getRow(),
                                 (parsedCell.getContents().trim().length() > 0 ? parsedCell.getContents() + ": " : "") + error.getErrorMessage());
    annotatedErrorSheet.addCell(errorLabel);
    
//  WritableCellFeatures cellFeatures = new WritableCellFeatures();
//  cellFeatures.setComment(error.getMessage());
//  errorAnnotatedCell.setCellFeatures(cellFeatures);
    
    // See [#1866]
    // TODO: this may be where we are getting the error messages:
    // "Warning:  Maximum number of format records exceeded.  Using default format."
    // which eventually results in a failure to write the error workbook.
    // see http://tech.groups.yahoo.com/group/JExcelApi/message/102
    // Unfortunately, the solution is not (has no effect):
    // errorLabel.setCellFormat(SOME_STATIC_FORMAT)
   
    WritableCellFormat newFormat = new WritableCellFormat();
    newFormat.setBackground(Colour.RED);
    errorLabel.setCellFormat(newFormat);
  }
 
开发者ID:hmsiccbl,项目名称:screensaver,代码行数:24,代码来源:ParseErrorManager.java


示例5: PaletteRecord

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Default constructor - used when there is no palette specified
 */
public PaletteRecord()
{
  super(Type.PALETTE);

  initialized = true;
  dirty = false;
  read = false;

  // Initialize the array with all the default colours
  Colour[] colours = Colour.getAllColours();

  for (int i = 0; i < colours.length; i++)
  {
    Colour c = colours[i];
    setColourRGB(c,
                 c.getDefaultRGB().getRed(),
                 c.getDefaultRGB().getGreen(),
                 c.getDefaultRGB().getBlue());
  }
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:24,代码来源:PaletteRecord.java


示例6: setColourRGB

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Sets the RGB value for the specified colour for this workbook
 *
 * @param c the colour whose RGB value is to be overwritten
 * @param r the red portion to set (0-255)
 * @param g the green portion to set (0-255)
 * @param b the blue portion to set (0-255)
 */
public void setColourRGB(Colour c, int r, int g, int b)
{
  // Only colours on the standard palette with values 8-64 are acceptable
  int pos = c.getValue() - 8;
  if (pos < 0 || pos >= numColours)
  {
    return;
  }

  if (!initialized)
  {
    initialize();
  }

  // Force the colours into the range 0-255
  r = setValueRange(r, 0, 0xff);
  g = setValueRange(g, 0, 0xff);
  b = setValueRange(b, 0, 0xff);

  rgbColours[pos] = new RGB(r, g, b);

  // Indicate that the palette has been modified
  dirty = true;
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:33,代码来源:PaletteRecord.java


示例7: getColourRGB

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Gets the colour RGB from the palette
 *
 * @param c the colour
 * @return an RGB structure
 */
public RGB getColourRGB(Colour c)
{
  // Only colours on the standard palette with values 8-64 are acceptable
  int pos = c.getValue() - 8;
  if (pos < 0 || pos >= numColours)
  {
    return c.getDefaultRGB();
  }

  if (!initialized)
  {
    initialize();
  }

  return rgbColours[pos];
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:23,代码来源:PaletteRecord.java


示例8: getLabelInfo

import jxl.format.Colour; //导入依赖的package包/类
/**
 * 根据错误信息进行提示--excel表格背景设置为红色,表示导入信息有误
 * @param cellInfo
 * @param cellNum
 * @param columnNum
 * @param value
 * @return
 */
private Label getLabelInfo(Map<Integer,String> cellInfo,int cellNum,int columnNum,String value,Material material)
{
	Label label = null;

	//设置背景颜色
	WritableCellFormat cellFormat = new WritableCellFormat();
	try
	{
		cellFormat.setBackground(Colour.RED);
	}
	catch (WriteException e)
	{
		Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>设置单元格背景颜色错误", e);
	}

	if(null == cellInfo || cellInfo.size() == 0) {
		label = new Label(cellNum, columnNum, value);
	}
	else {
		//表示此单元格有错误
		if(cellInfo.containsKey(cellNum)) {
			if(cellNum == MaterialConstants.BusinessForExcel.EXCEL_SAFETY_STOCK) {
				label = new Label(cellNum, columnNum, material.getSafetyStockStr(), cellFormat);
			}
		}
		else{
			label =  new Label(cellNum, columnNum, value);
		}
	}
	return label;
}
 
开发者ID:cendi2005,项目名称:jshERP,代码行数:40,代码来源:MaterialService.java


示例9: setBgColor

import jxl.format.Colour; //导入依赖的package包/类
private static void setBgColor(WritableCellFormat cellFormat, Color bgColor) {
	Colour colour = convertColor(bgColor);
	if (colour != null) {
		try {
			cellFormat.setBackground(colour);
		} catch (WriteException e) {
		}
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:ExcelUtil.java


示例10: createIndex

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Create the index worksheet.
 *
 * <p>This also creates links back to the index in each of the worksheets.</p>
 */
public void createIndex() {
  WritableSheet sheet = workbook.createSheet(spreadsheetifyName("Index"), 0);
  createTitle(sheet, "Index");

  try {
    // Create links for each worksheet, apart from the first sheet which is the
    // index we're currently creating
    final String[] names = workbook.getSheetNames();
    for (int currentSheet = 1; currentSheet < names.length; currentSheet++) {
      // Create the link from the index to the table's worksheet
      WritableHyperlink link = new WritableHyperlink(0, currentSheet - 1 + NUMBER_OF_ROWS_IN_TITLE, names[currentSheet], workbook.getSheet(currentSheet), 0, 0);
      sheet.addHyperlink(link);

      //Add the filename in column B (stored in cell B2 of each sheet)
      String fileName = workbook.getSheet(currentSheet).getCell(1, 1).getContents();
      Label fileNameLabel = new Label(1, currentSheet - 1 + NUMBER_OF_ROWS_IN_TITLE, fileName);
      WritableFont fileNameFont = new WritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
      WritableCellFormat fileNameFormat = new WritableCellFormat(fileNameFont);
      fileNameLabel.setCellFormat(fileNameFormat);
      sheet.addCell(fileNameLabel);

      // Create the link back to the index
      link = new WritableHyperlink(0, 1, "Back to index", sheet, 0, currentSheet + NUMBER_OF_ROWS_IN_TITLE - 1);
      workbook.getSheet(currentSheet).addHyperlink(link);
      //Set column A of each sheet to be wide enough to show "Back to index"
      workbook.getSheet(currentSheet).setColumnView(0, 13);
    }

    // Make Column A fairly wide to show tab names and hide column B
    sheet.setColumnView(0, 35);
    sheet.setColumnView(1, 0);

  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:42,代码来源:SpreadsheetDataSetConsumer.java


示例11: getBoldFormat

import jxl.format.Colour; //导入依赖的package包/类
/**
 * @return the format to use for bold cells
 * @throws WriteException if the format could not be created
 */
private WritableCellFormat getBoldFormat() throws WriteException {
  WritableFont boldFont = new WritableFont(WritableFont.ARIAL, 8, WritableFont.BOLD);
  WritableCellFormat boldHeading = new WritableCellFormat(boldFont);
  boldHeading.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
  boldHeading.setVerticalAlignment(VerticalAlignment.CENTRE);
  boldHeading.setBackground(Colour.GRAY_25);


  WritableCellFormat boldFormat = new WritableCellFormat(boldFont);
  boldFormat.setVerticalAlignment(VerticalAlignment.TOP);
  return boldFormat;
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:17,代码来源:TableOutputter.java


示例12: discover

import jxl.format.Colour; //导入依赖的package包/类
public Colour discover(Color color) {
    for (Colour colour : Colour.getAllColours()) {
        if ( colour.getDefaultRGB().getBlue() == color.getBlue()
                && colour.getDefaultRGB().getRed() == color.getRed()
                && colour.getDefaultRGB().getGreen() == color.getGreen() ) {
            return colour;
        }
    }
    return Colour.UNKNOWN;
}
 
开发者ID:gg-net,项目名称:dwoss,代码行数:11,代码来源:FormatUtil.java


示例13: getFormatRed

import jxl.format.Colour; //导入依赖的package包/类
/**
	 * @return the formatRed
	 */ 
	public WritableCellFormat getFormatRed() throws Exception{
//		if(formatRed == null){			
			formatRed=new WritableCellFormat();
			formatRed.setAlignment(jxl.format.Alignment.CENTRE);
			formatRed.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
			WritableFont wf_color = new WritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,Colour.RED);
			WritableCellFormat wff_color = new WritableCellFormat(wf_color);	
			formatRed.setBorder(Border.ALL, BorderLineStyle.THIN);
			formatRed.setFont(wf_color);				
			
//		}
		return formatRed;
	}
 
开发者ID:jview,项目名称:jtools,代码行数:17,代码来源:BaseExcel.java


示例14: write

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Uses the JExcelAPI to create a spreadsheet
 * 
 * @exception IOException
 * @exception WriteException
 */
public void write() throws IOException, WriteException
{
  WorkbookSettings ws = new WorkbookSettings();
  ws.setLocale(new Locale("en", "EN"));
  workbook = Workbook.createWorkbook(new File(filename), ws);


  WritableSheet s2 = workbook.createSheet("Number Formats", 0);
  WritableSheet s3 = workbook.createSheet("Date Formats", 1);
  WritableSheet s1 = workbook.createSheet("Label Formats", 2);
  WritableSheet s4 = workbook.createSheet("Borders", 3);
  WritableSheet s5 = workbook.createSheet("Labels", 4);
  WritableSheet s6 = workbook.createSheet("Formulas", 5);
  WritableSheet s7 = workbook.createSheet("Images", 6);
  //    WritableSheet s8 = workbook.createSheet
  //      ("'Illegal chars in name !*%^?': which exceeds max name length",7);

  // Modify the colour palette to bright red for the lime colour
  workbook.setColourRGB(Colour.LIME, 0xff, 0, 0);

  // Add a named range to the workbook
  workbook.addNameArea("namedrange", s4, 1, 11, 5, 14);
  workbook.addNameArea("validation_range", s1, 4, 65, 9, 65);
  workbook.addNameArea("formulavalue", s6, 1, 45, 1, 45);

  // Add a print area to the "Labels" sheet
  s5.getSettings().setPrintArea(4,4,15,35);

  writeLabelFormatSheet(s1);
  writeNumberFormatSheet(s2);
  writeDateFormatSheet(s3);
  writeBordersSheet(s4);
  writeLabelsSheet(s5);
  writeFormulaSheet(s6);
  writeImageSheet(s7);

  workbook.write();
  workbook.close();
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:46,代码来源:Write.java


示例15: setColourRGB

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Sets the RGB value for the specified colour for this workbook
 *
 * @param c the colour whose RGB value is to be overwritten
 * @param r the red portion to set (0-255)
 * @param g the green portion to set (0-255)
 * @param b the blue portion to set (0-255)
 */
public void setColourRGB(Colour c, int r, int g, int b)
{
  if (palette == null)
  {
    palette = new PaletteRecord();
  }
  palette.setColourRGB(c, r, g, b);
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:17,代码来源:FormattingRecords.java


示例16: getColourRGB

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Accessor for the RGB value for the specified colour
 *
 * @return the RGB for the specified colour
 */
public RGB getColourRGB(Colour c)
{
  if (palette == null)
  {
    return c.getDefaultRGB();
  }

  return palette.getColourRGB(c);
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:15,代码来源:FormattingRecords.java


示例17: getBackgroundColour

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Gets the background colour used by this cell
 *
 * @return the foreground colour
 */
public Colour getBackgroundColour()
{
  if (!formatInfoInitialized)
  {
    initializeFormatInformation();
  }

  return backgroundColour;
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:15,代码来源:XFRecord.java


示例18: setXFBorder

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Sets the border for this cell
 * This method should only be called from its writable subclass
 * CellXFRecord
 *
 * @param b the border
 * @param ls the border line style
 */
protected void setXFBorder(Border b, BorderLineStyle ls, Colour c)
{
  Assert.verify(!initialized);
  
  if (c == Colour.BLACK || c == Colour.UNKNOWN) 
  {
    c = Colour.PALETTE_BLACK;
  }

  if (b == Border.LEFT)
  {
    leftBorder = ls;
    leftBorderColour = c;
  }
  else if (b == Border.RIGHT)
  {
    rightBorder = ls;
    rightBorderColour = c;
  }
  else if (b == Border.TOP)
  {
    topBorder = ls;
    topBorderColour = c;
  }
  else if (b == Border.BOTTOM)
  {
    bottomBorder = ls;
    bottomBorderColour = c;
  }

  usedAttributes |= USE_BORDER;

  return;
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:43,代码来源:XFRecord.java


示例19: getBorderColour

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Gets the line style for the given cell border
 * If a border type of ALL or NONE is specified, then a line style of
 * NONE is returned
 *
 * @param border the cell border we are interested in
 * @return the line style of the specified border
 */
public Colour getBorderColour(Border border)
{
  // Don't bother with the short cut records
  if (border == Border.NONE ||
      border == Border.ALL)
  {
    return Colour.PALETTE_BLACK;
  }

  if (!formatInfoInitialized)
  {
    initializeFormatInformation();
  }

  if (border == Border.LEFT)
  {
    return leftBorderColour;
  }
  else if (border == Border.RIGHT)
  {
    return rightBorderColour;
  }
  else if (border == Border.TOP)
  {
    return topBorderColour;
  }
  else if (border == Border.BOTTOM)
  {
    return bottomBorderColour;
  }

  return Colour.BLACK;  	
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:42,代码来源:XFRecord.java


示例20: WritableFont

import jxl.format.Colour; //导入依赖的package包/类
/**
 * Creates a default font, vanilla font of the specified face and with
 * default point size.
 *
 * @param fn the font name
 */
public WritableFont(FontName fn)
{
  this(fn,
       DEFAULT_POINT_SIZE,
       NO_BOLD,
       false,
       UnderlineStyle.NO_UNDERLINE,
       Colour.BLACK,
       ScriptStyle.NORMAL_SCRIPT);
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:17,代码来源:WritableFont.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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