當前位置: 首頁>>代碼示例>>Java>>正文


Java WritableCellFormat.setBackground方法代碼示例

本文整理匯總了Java中jxl.write.WritableCellFormat.setBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java WritableCellFormat.setBackground方法的具體用法?Java WritableCellFormat.setBackground怎麽用?Java WritableCellFormat.setBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jxl.write.WritableCellFormat的用法示例。


在下文中一共展示了WritableCellFormat.setBackground方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: format

import jxl.write.WritableCellFormat; //導入方法依賴的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: format

import jxl.write.WritableCellFormat; //導入方法依賴的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(jxl.format.Colour.LIGHT_BLUE);
        arial12font = new WritableFont(WritableFont.ARIAL, 12);
        arial12format = new WritableCellFormat(arial12font);
        arial12format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
    } catch (WriteException e) {

        e.printStackTrace();
    }
}
 
開發者ID:qiu-yongheng,項目名稱:Bluetooth_BLE,代碼行數:22,代碼來源:ExcelUtils.java

示例3: annotateCellWithError

import jxl.write.WritableCellFormat; //導入方法依賴的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

示例4: setBgColor

import jxl.write.WritableCellFormat; //導入方法依賴的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

示例5: getBoldFormat

import jxl.write.WritableCellFormat; //導入方法依賴的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

示例6: outputDataHeadings

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
/**
 * Outputs the data headings row.
 *
 * @param workSheet to add the row to
 * @param table to fetch metadata from
 * @param startRow to add the headings at
 * @param helpTextRowNumbers - the map of column names to row index for each
 *   bit of help text
 * @throws WriteException if any of the writes to workSheet failed
 * @return the row to carry on inserting at
 */
private int outputDataHeadings(WritableSheet workSheet, Table table, final int startRow, final Map<String, Integer> helpTextRowNumbers) throws WriteException {
  int currentRow = startRow;

  int columnNumber = 0;
  final WritableCellFormat columnHeadingFormat = getBoldFormat();

  columnHeadingFormat.setBackground(Colour.VERY_LIGHT_YELLOW);
  WritableFont font = new WritableFont(WritableFont.ARIAL, 8, WritableFont.BOLD);
  font.setColour(Colour.BLUE);
  font.setUnderlineStyle(UnderlineStyle.SINGLE);
  columnHeadingFormat.setFont(font);

  for (Column column : table.columns()) {

    if(columnNumber < MAX_EXCEL_COLUMNS && !column.getName().equals("id") && !column.getName().equals("version")) {
      // Data heading is a link back to the help text
      WritableHyperlink linkToHelp = new WritableHyperlink(
        columnNumber, currentRow,
        spreadsheetifyName(column.getName()),
        workSheet, 0, helpTextRowNumbers.get(column.getName()));
      workSheet.addHyperlink(linkToHelp);
      WritableCell label = workSheet.getWritableCell(columnNumber, currentRow);
      label.setCellFormat(columnHeadingFormat);

      // Update the help text such that it is a link to the heading
      Cell helpCell = workSheet.getCell(0, helpTextRowNumbers.get(column.getName()));
      WritableHyperlink linkFromHelp = new WritableHyperlink(
        0, helpTextRowNumbers.get(column.getName()),
        helpCell.getContents(),
        workSheet, columnNumber, currentRow);
      workSheet.addHyperlink(linkFromHelp);

      columnNumber++;
    }
  }

  currentRow++;

  return currentRow;
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:52,代碼來源:TableOutputter.java

示例7: setParam

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
private WritableCellFormat setParam(WritableCellFormat wcf, int map) throws WriteException {
	if ( (map&CENTRE)!=0 ) 		wcf.setAlignment(Alignment.CENTRE);
	if ( (map&RIGHT)!=0 ) 		wcf.setAlignment(Alignment.RIGHT);
	if ( (map&LEFT)!=0 ) 		wcf.setAlignment(Alignment.LEFT);
	if ( (map&VCENTRE)!=0 ) 	wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
	
	if ( (map&B_TOP_MED)!=0 ) 	wcf.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
	if ( (map&B_BOTTOM_MED)!=0 ) wcf.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
	if ( (map&B_LEFT_MED)!=0 ) 	wcf.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
	if ( (map&B_RIGHT_MED)!=0 ) wcf.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
	
	if ( (map&B_ALL_MED)!=0 ) {
		wcf.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
		wcf.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
		wcf.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
		wcf.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
	}
	
	if ( (map&B_TOP_LOW)!=0 ) 	wcf.setBorder(Border.TOP, BorderLineStyle.THIN);
	if ( (map&B_BOTTOM_LOW)!=0 ) wcf.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
	if ( (map&B_LEFT_LOW)!=0 ) 	wcf.setBorder(Border.LEFT, BorderLineStyle.THIN);
	if ( (map&B_RIGHT_LOW)!=0 ) wcf.setBorder(Border.RIGHT, BorderLineStyle.THIN);
	
	if ( (map&B_ALL_LOW)!=0 ) {
		wcf.setBorder(Border.RIGHT, BorderLineStyle.THIN);
		wcf.setBorder(Border.LEFT, BorderLineStyle.THIN);
		wcf.setBorder(Border.TOP, BorderLineStyle.THIN);
		wcf.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
	}
	
	if ( (map&GRAY_25)!=0 ) wcf.setBackground(Colour.GRAY_25);
	if ( (map&GREEN)!=0 ) wcf.setBackground(Colour.LIGHT_GREEN);
	if ( (map&BLACK)!=0 ) wcf.setBackground(Colour.BLACK);
	if ( (map&YELLOW)!=0 ) wcf.setBackground(Colour.YELLOW);
	if ( (map&RED)!=0 ) wcf.setBackground(Colour.RED);
	
	if ( (map&WRAP)!=0 ) wcf.setWrap(true);
	
	if ( (map&DIAG45)!=0 ) wcf.setOrientation(Orientation.PLUS_45);
	

	
	return wcf;
}
 
開發者ID:vagfed,項目名稱:hmcScanner,代碼行數:45,代碼來源:Loader.java

示例8: generateExcelReport

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
public void generateExcelReport()
{
    if(this.reports.isEmpty())
        {
            this.status = "There is no data yet";
            this.success = false;
            this.exception = "Please run linkcrawler at least once in order to be able to generate a report";
            return;
        }
    try {            
        String reportDir = System.getProperty("user.dir") + File.separatorChar + "Reports";
        Date date = new Date();
        DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd__HH_mm_ss");
        String reportDirFile = reportDir + File.separatorChar + "Report_" + dateFormat.format(date);
        reportLocation = reportDirFile;            
        String reportExcelFile = reportDirFile + File.separatorChar + "ReportExcel.xls";            
        File reportDirPointer = new File(reportDir);
        File reportDirFilePointer = new File(reportDirFile);            
        //Creating directories if not there
        if(!reportDirFilePointer.exists())
        {
            reportDirPointer.mkdir();
            reportDirFilePointer.mkdir();                
        }
        File reportExcelFilePointer = new File(reportExcelFile);
        reportExcelFilePointer.createNewFile();            
        WritableWorkbook workbook = Workbook.createWorkbook(reportExcelFilePointer);            
        int sheetNumber = 0;
        for(UrlReport ur : reports)
        {
            WritableSheet sheet = workbook.createSheet("Crawled Url " + (sheetNumber + 1), sheetNumber++);
            WritableFont blackHeadersFont = new WritableFont(WritableFont.ARIAL, 8, WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE, Colour.WHITE);
            WritableCellFormat blackHeadersFormatBackground = new WritableCellFormat();
            blackHeadersFormatBackground.setBackground(Colour.BLUE) ;
            blackHeadersFormatBackground.setBorder(Border.ALL, BorderLineStyle.THIN,Colour.BLACK);
            blackHeadersFormatBackground.setFont(blackHeadersFont);
            blackHeadersFormatBackground.setAlignment(Alignment.LEFT);
            WritableFont whiteValueFont = new WritableFont(WritableFont.ARIAL, 8, WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
            WritableCellFormat whiteValueFormatBackground = new WritableCellFormat();
            whiteValueFormatBackground.setBackground(Colour.WHITE);
            whiteValueFormatBackground.setBorder(Border.ALL, BorderLineStyle.THIN,Colour.BLACK);
            whiteValueFormatBackground.setFont(whiteValueFont);
            whiteValueFormatBackground.setAlignment(Alignment.LEFT);
            Label introLabel = new Label(0, 0, "Site:", blackHeadersFormatBackground);
            Label introLabelValue = new Label(1, 0, ur.getPageUrl()+"         ", whiteValueFormatBackground);
            sheet.addCell(introLabel);
            sheet.addCell(introLabelValue);  
            int staringRow = 0;                
            staringRow = prepareLinksDataDetail(sheet, ur, staringRow, LinkTypes.INTERNAL, "Internal links   ", blackHeadersFormatBackground, whiteValueFormatBackground);
            staringRow = prepareLinksDataDetail(sheet, ur, staringRow, LinkTypes.EXTERNAL, "External links   ", blackHeadersFormatBackground, whiteValueFormatBackground);
            staringRow = prepareLinksDataDetail(sheet, ur, staringRow, LinkTypes.SPECIAL, "Special links   ", blackHeadersFormatBackground, whiteValueFormatBackground);
            staringRow = prepareLinksDataDetail(sheet, ur, staringRow, LinkTypes.IMAGES, "Images   ", blackHeadersFormatBackground, whiteValueFormatBackground);
             for(int x=0; x < sheet.getColumns(); x++)
            {
                CellView cell=sheet.getColumnView(x);
                cell.setAutosize(true);
                sheet.setColumnView(x, cell);
            }                
        }       
        workbook.write(); 
        workbook.close();
        this.status = "Excel report generated";
    } catch (Exception ex) {
        this.status = "Error when generating Excel File";
        this.success = false;
        this.exception = ex.getMessage();
    }
}
 
開發者ID:fanghon,項目名稱:webmonitor,代碼行數:69,代碼來源:ReportController.java

示例9: writeTo

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
private void writeTo( WritableWorkbook workbook, String sheetName, NList data ) throws WriteException {

        WritableSheet sheet = workbook.createSheet( sheetName, workbook.getNumberOfSheets() );

        // Write Header

        WritableCellFormat headerCellFormat = new WritableCellFormat();

        headerCellFormat.setBorder( Border.ALL, BorderLineStyle.THIN );
        headerCellFormat.setBackground( Colour.GRAY_25 );

        int column = 0;

        for( String alias : data.getAliases() ) {
            sheet.addCell( new Label( column++, 0, toExcelText( alias ), headerCellFormat ) );
        }

        // Write Body

        WritableCellFormat bodyCellFormat = new WritableCellFormat();

        bodyCellFormat.setBorder( Border.ALL, BorderLineStyle.THIN );

        int rowCnt = data.size();
        int colCnt = data.keySize();

        for( int row = 0; row < rowCnt; row++ ) {

            for( int col = 0; col < colCnt; col++ ) {
                sheet.addCell( new Label( col, row + 1, toExcelText( data.get( data.getKey( col ), row ) ), bodyCellFormat ) );
            }

        }

    }
 
開發者ID:NyBatis,項目名稱:NyBatisCore,代碼行數:36,代碼來源:ExcelHandlerJxl.java


注:本文中的jxl.write.WritableCellFormat.setBackground方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。