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


Java WritableCellFormat.setAlignment方法代碼示例

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


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

示例1: setExcelListTitle

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
/**
 * 設置報表內容頭
 * 
 * @param listTitle
 *            報表頭
 * @throws IOException
 * @throws WriteException
 */
@Deprecated
public void setExcelListTitle(String[] listTitle) throws WriteException, IOException {
    try {
        irow++;
        long start = System.currentTimeMillis();
        wfont = new WritableFont(WritableFont.createFont("宋體"), 10, WritableFont.BOLD, false,
            UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
        wcfFC = new WritableCellFormat(wfont);
        wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM);
        wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
        wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
        for (int i = icol; i < listTitle.length; i++) {
            wsheet.addCell(new Label(i, irow, listTitle[i], wcfFC));
        }
        trow = irow;
        logger.info("title use time:" + (System.currentTimeMillis() - start));
    } catch (Exception e) {
        this.close();
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:29,代碼來源:DownloadExcelUtil.java

示例2: setReportTitle

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
/**
 * 設置報表標題
 * 
 * @param reportTitle
 *            報表標題
 * @throws IOException
 * @throws WriteException
 * @throws WriteException
 */
public void setReportTitle(String reportTitle) throws WriteException, IOException {
    try {
        irow++;
        wfont = new WritableFont(WritableFont.createFont("宋體"), 12, WritableFont.BOLD, false,
            UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
        wcfFC = new WritableCellFormat(wfont);
        wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
        // wcfFC.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);// 背景色
        wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
        // wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM,
        // Colour.BLACK);//
        // 邊框
        wsheet.addCell(new Label(icol, irow, reportTitle, wcfFC));
        trow = irow;
    } catch (Exception e) {
        this.close();
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:28,代碼來源:DownloadExcelUtil.java

示例3: setExcelListTitle

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
/**
 * 設置報表內容頭
 * 
 * @param listTitle
 *            報表頭
 * @throws IOException
 * @throws WriteException
 */
@Deprecated
public void setExcelListTitle(String[] listTitle) throws WriteException, IOException {
    try {
        irow++;
        long start = System.currentTimeMillis();
        wfont = new WritableFont(WritableFont.createFont("宋體"), 10, WritableFont.BOLD, false,
            UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
        wcfFC = new WritableCellFormat(wfont);
        wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM);
        wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
        wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
        for (int i = icol; i < listTitle.length; i++) {
            wsheet.addCell(new Label(i, irow, listTitle[i], wcfFC));
        }
        trow = irow;
        log.info("title use time:" + (System.currentTimeMillis() - start));
    } catch (Exception e) {
        this.close();
    }
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:29,代碼來源:DownloadExcelUtil.java

示例4: 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

示例5: 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

示例6: getHeader

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

示例7: writeCell

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
/**
 * @param columnPosition - column to place new cell in
 * @param rowPosition - row to place new cell in
 * @param contents - string value to place in cell
 * @param headerCell - whether to give this cell special formatting
 * @param sheet - WritableSheet to place cell in
 * @throws RowsExceededException - thrown if adding cell exceeds .xls row limit
 * @throws WriteException - Idunno, might be thrown
 */
public void writeCell(int columnPosition, int rowPosition, String contents, boolean headerCell,
    WritableSheet sheet) throws RowsExceededException, WriteException{
    //create a new cell with contents at position
    Label newCell = new Label(columnPosition,rowPosition,contents);
 
    if (headerCell){
        //give header cells size 10 Arial bolded 	
        WritableFont headerFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);
        WritableCellFormat headerFormat = new WritableCellFormat(headerFont);
        //center align the cells' contents
        headerFormat.setAlignment(Alignment.CENTRE);
        newCell.setCellFormat(headerFormat);
    }
 
    sheet.addCell(newCell);
}
 
開發者ID:jonathanbsilva,項目名稱:Phonegap-XLS-Plugin,代碼行數:26,代碼來源:Xls.java

示例8: getAlignment

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
public static WritableCellFormat getAlignment(int stepValue, WritableCellFormat format) throws WriteException
{
	 if(stepValue!=ExcelOutputMeta.FONT_ALIGNMENT_LEFT)
	 {
	   switch(stepValue)
       {
            case ExcelOutputMeta.FONT_ALIGNMENT_RIGHT:
            	format.setAlignment(jxl.format.Alignment.RIGHT);
            break;
            case ExcelOutputMeta.FONT_ALIGNMENT_CENTER:
            	format.setAlignment(jxl.format.Alignment.CENTRE);
            break;
            case ExcelOutputMeta.FONT_ALIGNMENT_FILL:
            	format.setAlignment(jxl.format.Alignment.FILL);
            break;
            case ExcelOutputMeta.FONT_ALIGNMENT_GENERAL:
            	format.setAlignment(jxl.format.Alignment.GENERAL);
            break;
            case ExcelOutputMeta.FONT_ALIGNMENT_JUSTIFY:
            	format.setAlignment(jxl.format.Alignment.JUSTIFY);
            break;
            default: break;
        }
	 }
	return format;
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:27,代碼來源:ExcelFontMap.java

示例9: getAlignment

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
public static WritableCellFormat getAlignment( int stepValue, WritableCellFormat format ) throws WriteException {
  if ( stepValue != ExcelOutputMeta.FONT_ALIGNMENT_LEFT ) {
    switch ( stepValue ) {
      case ExcelOutputMeta.FONT_ALIGNMENT_RIGHT:
        format.setAlignment( jxl.format.Alignment.RIGHT );
        break;
      case ExcelOutputMeta.FONT_ALIGNMENT_CENTER:
        format.setAlignment( jxl.format.Alignment.CENTRE );
        break;
      case ExcelOutputMeta.FONT_ALIGNMENT_FILL:
        format.setAlignment( jxl.format.Alignment.FILL );
        break;
      case ExcelOutputMeta.FONT_ALIGNMENT_GENERAL:
        format.setAlignment( jxl.format.Alignment.GENERAL );
        break;
      case ExcelOutputMeta.FONT_ALIGNMENT_JUSTIFY:
        format.setAlignment( jxl.format.Alignment.JUSTIFY );
        break;
      default:
        break;
    }
  }
  return format;
}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:25,代碼來源:ExcelFontMap.java

示例10: generateWriteableCellFormats

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
protected Map<CellFormat, WritableCellFormat> generateWriteableCellFormats(WritableCellFormat base) {
    try {
        WritableFont bold = new WritableFont(WritableFont.createFont(base.getFont().getName()), 
            base.getFont().getPointSize(), WritableFont.BOLD);
        
        Map<CellFormat, WritableCellFormat> result = new HashMap<>();
        for (boolean isCentered : new boolean[] { true, false }) {
            for (boolean isBold : new boolean[] { true, false }) {
                for (boolean hasTopBorder : new boolean[] { true, false }) {
                    CellFormat f = new CellFormat();
                    f.isCentered = isCentered;
                    f.isBold = isBold;
                    f.hasTopBorder = hasTopBorder;
                    
                    WritableCellFormat format = new WritableCellFormat(base);
                    if (isCentered) format.setAlignment(Alignment.CENTRE);
                    if (isBold) format.setFont(bold);
                    if (hasTopBorder) format.setBorder(Border.TOP, BorderLineStyle.THIN);
    
                    result.put(f, format);
                }
            }
        }
        return result;
    }
    catch (WriteException e) { throw new RuntimeException(e); }
}
 
開發者ID:onestopconcept,項目名稱:onestop-endpoints,代碼行數:28,代碼來源:ExcelGenerator.java

示例11: getFormat

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
/**
	 * @return the format1
	 */
	public WritableCellFormat getFormat() throws Exception{
//		if(format==null){
		    format=new WritableCellFormat();
		    format.setAlignment(jxl.format.Alignment.LEFT);
		    format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
		    format.setBorder(Border.ALL, BorderLineStyle.THIN);
		 
//		}
		return format;
	}
 
開發者ID:jview,項目名稱:jtools,代碼行數:14,代碼來源:BaseExcel.java

示例12: getFormatRed

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

示例13: getFormatCenter

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
/**
	 * @return the formatCenter
	 */
	public WritableCellFormat getFormatCenter() throws Exception{
//		if(formatCenter==null){
			formatCenter=new WritableCellFormat();
			formatCenter.setAlignment(jxl.format.Alignment.CENTRE);
			formatCenter.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
			formatCenter.setBorder(Border.ALL, BorderLineStyle.THIN);
		 
//		}
		return formatCenter;
	}
 
開發者ID:jview,項目名稱:jtools,代碼行數:14,代碼來源:BaseExcel.java

示例14: createCellFormats

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
/**
 * In order to set text to bold, red, or green, we need to create cell
 * formats for each style.
 */
private void createCellFormats() {

    // Insert a dummy empty cell, so we can obtain its cell. This allows to
    // start with a default cell format.
    Label cell = new Label(0, 0, " ");
    CellFormat cellFormat = cell.getCellFormat();

    try {
        // Create the bold format
        final WritableFont boldFont = new WritableFont(cellFormat.getFont());
        mBoldFormat = new WritableCellFormat(cellFormat);
        boldFont.setBoldStyle(WritableFont.BOLD);
        mBoldFormat.setFont(boldFont);
        mBoldFormat.setAlignment(Alignment.CENTRE);

        // Center other formats
        mDefaultFormat = new WritableCellFormat(cellFormat);
        mDefaultFormat.setAlignment(Alignment.CENTRE);
        mLongDurationFormat.setAlignment(Alignment.CENTRE);
        mShortDurationFormat.setAlignment(Alignment.CENTRE);
        mDateFormat.setAlignment(Alignment.CENTRE);


    } catch (WriteException e) {
        Log.e(TAG, "createCellFormats Could not create cell formats", e);
    }
}
 
開發者ID:caarmen,項目名稱:scrumchatter,代碼行數:32,代碼來源:MeetingsExport.java

示例15: center

import jxl.write.WritableCellFormat; //導入方法依賴的package包/類
private WritableCell center(WritableCell cell) throws WriteException {
	WritableCellFormat format = new WritableCellFormat(cell.getCellFormat());
	format.setAlignment(Alignment.CENTRE);
	cell.setCellFormat(format);
	return cell;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:7,代碼來源:ExcelReport.java


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