当前位置: 首页>>代码示例>>Java>>正文


Java Alignment类代码示例

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


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

示例1: setExcelListTitle

import jxl.format.Alignment; //导入依赖的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.format.Alignment; //导入依赖的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.format.Alignment; //导入依赖的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: getCellFormat

import jxl.format.Alignment; //导入依赖的package包/类
/**
 * 通用的样式设置
 *
 * @param format    单元格样式
 * @param alignment 水平对齐方式
 * @return 通用的样式设置
 */
private static WritableCellFormat getCellFormat(WritableCellFormat format, Alignment alignment) {

    try {
        format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        format.setAlignment(alignment);
        format.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
        format.setBorder(Border.LEFT, BorderLineStyle.THIN);
        format.setBorder(Border.RIGHT, BorderLineStyle.THIN);
        format.setBorder(Border.TOP, BorderLineStyle.THIN);
    } catch (WriteException e) {
        return format;
    }
    return format;

}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:23,代码来源:ExportUtil.java

示例5: ExportExcelUtil

import jxl.format.Alignment; //导入依赖的package包/类
public ExportExcelUtil() throws WriteException {

		titleFormat.setBorder(Border.ALL, BorderLineStyle.THIN); // 线条
		titleFormat.setVerticalAlignment(VerticalAlignment.CENTRE);

		titleFormat.setAlignment(Alignment.CENTRE); // 文字对齐
		titleFormat.setWrap(false); // 文字是否换行

		contentCenterFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
		contentCenterFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
		contentCenterFormat.setAlignment(Alignment.CENTRE);
		contentCenterFormat.setWrap(false);

		contentRightFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
		contentRightFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
		contentRightFormat.setAlignment(Alignment.RIGHT);
		contentRightFormat.setWrap(false);
	}
 
开发者ID:giantray,项目名称:ExcelTool,代码行数:19,代码来源:ExportExcelUtil.java

示例6: writeCell

import jxl.format.Alignment; //导入依赖的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

示例7: generateWriteableCellFormats

import jxl.format.Alignment; //导入依赖的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

示例8: getTitleFormat

import jxl.format.Alignment; //导入依赖的package包/类
/**
 * 标题样式
 *
 * @return 标题样式
 */
private static WritableCellFormat getTitleFormat() {
    WritableFont titleFont = new WritableFont(WritableFont.TIMES, 18, WritableFont.BOLD, false);
    WritableCellFormat title = new WritableCellFormat(titleFont);
    title = getCellFormat(title, Alignment.CENTRE);
    try {
        title.setWrap(true);
    } catch (WriteException e) {
        return title;
    }
    return title;
}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:17,代码来源:ExportUtil.java

示例9: getHeaderFormat

import jxl.format.Alignment; //导入依赖的package包/类
/**
 * 表头样式
 */
private static WritableCellFormat getHeaderFormat() {
    WritableFont headFont = new WritableFont(WritableFont.TIMES, 12, WritableFont.BOLD, false);
    WritableCellFormat head = new WritableCellFormat(headFont);
    head = getCellFormat(head, Alignment.CENTRE);
    return head;
}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:10,代码来源:ExportUtil.java

示例10: getLeftFormat

import jxl.format.Alignment; //导入依赖的package包/类
/**
 * 居左样式
 */
private static WritableCellFormat getLeftFormat() {
    WritableCellFormat left = new WritableCellFormat(FONT_BODY);
    left = getCellFormat(left, Alignment.LEFT);
    try {
        left.setWrap(true);
    } catch (WriteException ex) {
        return left;
    }
    return left;
}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:14,代码来源:ExportUtil.java

示例11: getRightFormat

import jxl.format.Alignment; //导入依赖的package包/类
/**
 * 居右样式
 */
private static WritableCellFormat getRightFormat() {
    WritableCellFormat left = new WritableCellFormat(FONT_BODY);
    left = getCellFormat(left, Alignment.RIGHT);
    try {
        left.setWrap(true);
    } catch (WriteException ex) {
        return left;
    }
    return left;
}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:14,代码来源:ExportUtil.java

示例12: getNumberFormat

import jxl.format.Alignment; //导入依赖的package包/类
/**
 * 数字样式
 */
private static WritableCellFormat getNumberFormat(String format) {
    NumberFormat nf = new NumberFormat(format);
    WritableCellFormat number = new WritableCellFormat(nf);
    number.setFont(FONT_BODY);
    number = getCellFormat(number, Alignment.CENTRE);
    return number;
}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:11,代码来源:ExportUtil.java

示例13: discover

import jxl.format.Alignment; //导入依赖的package包/类
public Alignment discover(eu.ggnet.lucidcalc.CFormat.HorizontalAlignment horizontalAlignment) {
    switch (horizontalAlignment) {
        case CENTER:
            return Alignment.CENTRE;
        case LEFT:
            return Alignment.LEFT;
        case RIGHT:
            return Alignment.RIGHT;
    }
    return Alignment.GENERAL;
}
 
开发者ID:gg-net,项目名称:dwoss,代码行数:12,代码来源:FormatUtil.java

示例14: createCellFormats

import jxl.format.Alignment; //导入依赖的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: getAlignment

import jxl.format.Alignment; //导入依赖的package包/类
/**
 * Gets the horizontal cell alignment
 *
 * @return the alignment
 */
public Alignment getAlignment()
{
  if (!formatInfoInitialized)
  {
    initializeFormatInformation();
  }

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


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