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


Java WritableCellFormat.setVerticalAlignment方法代码示例

本文整理汇总了Java中jxl.write.WritableCellFormat.setVerticalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java WritableCellFormat.setVerticalAlignment方法的具体用法?Java WritableCellFormat.setVerticalAlignment怎么用?Java WritableCellFormat.setVerticalAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jxl.write.WritableCellFormat的用法示例。


在下文中一共展示了WritableCellFormat.setVerticalAlignment方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

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

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

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

示例9: getStandardFormat

import jxl.write.WritableCellFormat; //导入方法依赖的package包/类
/**
 * @return the format to use for normal cells
 * @throws WriteException if the format could not be created
 */
private WritableCellFormat getStandardFormat() throws WriteException {
  WritableCellFormat standardFormat = new WritableCellFormat(getStandardFont());
  standardFormat.setVerticalAlignment(VerticalAlignment.TOP);
  return standardFormat;
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:10,代码来源:TableOutputter.java

示例10: outputHelp

import jxl.write.WritableCellFormat; //导入方法依赖的package包/类
/**
 * @param workSheet to add the help to
 * @param table to fetch metadata from
 * @param startRow to start adding rows at
 * @param helpTextRowNumbers - map to insert row numbers for each help field into
 * @return the index of the next row to use
 * @throws WriteException if any of the writes to workSheet failed
 */
private int outputHelp(WritableSheet workSheet, Table table, final int startRow, final Map<String, Integer> helpTextRowNumbers) throws WriteException {
  int currentRow = startRow;

  // Title for the descriptions
  Label dataLabel = new Label(0, currentRow, "Column Descriptions");
  dataLabel.setCellFormat(getBoldFormat());
  workSheet.addCell(dataLabel);
  currentRow++;

  int currentColumn = 0;

  for (Column column : table.columns()) {
    if (!column.getName().equals("id") && !column.getName().equals("version")) {
      // Field name to go with the description
      Label fieldName = new Label(0, currentRow, spreadsheetifyName(column.getName()));
      fieldName.setCellFormat(getBoldFormat());
      workSheet.addCell(fieldName);

      // The type/width
      String typeString = column.getType() + "(" + column.getWidth() + (column.getScale() == 0 ? "" : "," + column.getScale()) + ")";
      Label fieldType = new Label(1, currentRow, typeString);
      fieldType.setCellFormat(getStandardFormat());
      workSheet.addCell(fieldType);

      // The default
      String defaultValue = additionalSchemaData.columnDefaultValue(table, column.getName());
      Label fieldDefault = new Label(2, currentRow, defaultValue);
      fieldDefault.setCellFormat(getStandardFormat());
      workSheet.addCell(fieldDefault);

      // The field documentation
      workSheet.mergeCells(3, currentRow, 12, currentRow);
      String documentation = additionalSchemaData.columnDocumentation(table, column.getName());
      Label documentationLabel = new Label(3, currentRow, documentation);
      WritableCellFormat format = new WritableCellFormat(getStandardFormat());
      format.setWrap(true);
      format.setVerticalAlignment(VerticalAlignment.TOP);
      documentationLabel.setCellFormat(format);
      workSheet.addCell(documentationLabel);

      //If we've exceed the maximum number of columns - then output truncated warnings
      if(currentColumn >= MAX_EXCEL_COLUMNS) {
        Label truncatedWarning = new Label(13, currentRow, "[TRUNCATED]");
        truncatedWarning.setCellFormat(getBoldFormat());
        workSheet.addCell(truncatedWarning);
      }

      // We are aiming for 150px. 1px is 15 Excel "Units"
      workSheet.setRowView(currentRow, 150 * 15);

      // Remember at what row we created the help text for this column
      helpTextRowNumbers.put(column.getName(), currentRow);

      currentRow++;
      currentColumn++;
    }

  }

  // Group all the help rows together
  workSheet.setRowGroup(startRow + 1, currentRow - 1, true);

  // Some extra blank space for neatness
  currentRow++;

  return currentRow;
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:76,代码来源:TableOutputter.java

示例11: exportExcel

import jxl.write.WritableCellFormat; //导入方法依赖的package包/类
/***************************************************************************
  * @param <T>
  * @param fileName EXCEL文件名称
  * @param listTitle EXCEL文件第一行列标题集合
  * @param listContent EXCEL文件正文数据集合
  * @return
 * @throws Exception 
  */
 @SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> void exportExcel(String fileName, String[] Title, List<T> contents, WritingOneRowHandler writingHandler, HttpServletResponse response) 
										throws Exception {

	  OutputStream os = null;
	  os = response.getOutputStream();
	  response.reset();
	   response.setHeader("Content-disposition", "attachment; filename="+ new String(fileName.getBytes("GB2312"),"ISO8859-1"));
	   response.setContentType("application/msexcel");// 定义输出类型    

	   /** **********创建工作表 ************ */
	   WritableWorkbook workbook = Workbook.createWorkbook(os);

	   /** **********创建工作表************ */

	   WritableSheet sheet = workbook.createSheet("虚机信息列表", 0);

	   /** **********设置纵横打印(默认为纵打)、打印纸***************** */
	   jxl.SheetSettings sheetset = sheet.getSettings();
	   sheetset.setProtected(false);


	   /** ************设置单元格字体************** */
	   WritableFont NormalFont = new WritableFont(WritableFont.COURIER, 10);
	   WritableFont BoldFont = new WritableFont(WritableFont.COURIER, 10,WritableFont.BOLD);

	   /** ************以下设置三种单元格样式,灵活备用************ */
	   // 用于标题居中
	   WritableCellFormat wcf_center = new WritableCellFormat(BoldFont);
	   wcf_center.setBorder(Border.ALL, BorderLineStyle.THIN); // 线条
	   wcf_center.setVerticalAlignment(VerticalAlignment.CENTRE); // 文字垂直对齐
	   wcf_center.setAlignment(Alignment.CENTRE); // 文字水平对齐
	   wcf_center.setWrap(false); // 文字是否换行
	   
	   // 用于正文居左
	   WritableCellFormat wcf_left = new WritableCellFormat(NormalFont);
	   wcf_left.setBorder(Border.NONE, BorderLineStyle.THIN); // 线条
	   wcf_left.setVerticalAlignment(VerticalAlignment.CENTRE); // 文字垂直对齐
	   wcf_left.setAlignment(Alignment.LEFT); // 文字水平对齐
	   wcf_left.setWrap(true); // 文字是否换行   
	 
	   /** ***************以下是EXCEL第一行列标题********************* */
	   for (int col = 0; col < Title.length; col++) {
	    sheet.addCell(new Label(col, 0,Title[col], wcf_center));
	   }  
	   
	   /** ***************以下是EXCEL正文数据********************* */
	   int rowNo = 1;
	   for(T obj: contents){
		   writingHandler.write(obj, rowNo, sheet, wcf_left);
		   rowNo++;
	   }
	   /** **********将以上缓存中的内容写到EXCEL文件中******** */
	   workbook.write();
	   /** *********关闭文件************* */
	   workbook.close();   
 }
 
开发者ID:shuqin,项目名称:ALLIN,代码行数:66,代码来源:ExcelUtils.java

示例12: writeExcel

import jxl.write.WritableCellFormat; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> boolean writeExcel(File file, String[] Title, List<T> contents, @SuppressWarnings("rawtypes") WritingOneRowHandler writingHandler) {

	  try {    

		   /** **********创建工作表 ************ */
		   WritableWorkbook workbook = Workbook.createWorkbook(file);

		   /** **********创建工作表************ */

		   WritableSheet sheet = workbook.createSheet("虚机信息列表", 0);

		   /** **********设置纵横打印(默认为纵打)、打印纸***************** */
		   jxl.SheetSettings sheetset = sheet.getSettings();
		   sheetset.setProtected(false);


		   /** ************设置单元格字体************** */
		   WritableFont NormalFont = new WritableFont(WritableFont.COURIER, 10);
		   WritableFont BoldFont = new WritableFont(WritableFont.COURIER, 10,WritableFont.BOLD);

		   /** ************以下设置三种单元格样式,灵活备用************ */
		   // 用于标题居中
		   WritableCellFormat wcf_center = new WritableCellFormat(BoldFont);
		   wcf_center.setBorder(Border.ALL, BorderLineStyle.THIN); // 线条
		   wcf_center.setVerticalAlignment(VerticalAlignment.CENTRE); // 文字垂直对齐
		   wcf_center.setAlignment(Alignment.CENTRE); // 文字水平对齐
		   wcf_center.setWrap(false); // 文字是否换行
		   
		   // 用于正文居左
		   WritableCellFormat wcf_left = new WritableCellFormat(NormalFont);
		   wcf_left.setBorder(Border.NONE, BorderLineStyle.THIN); // 线条
		   wcf_left.setVerticalAlignment(VerticalAlignment.CENTRE); // 文字垂直对齐
		   wcf_left.setAlignment(Alignment.LEFT); // 文字水平对齐
		   wcf_left.setWrap(true); // 文字是否换行   
		 
		   /** ***************以下是EXCEL第一行列标题********************* */
		   for (int col = 0; col < Title.length; col++) {
		    sheet.addCell(new Label(col, 0,Title[col], wcf_center));
		   }  
		   
		   /** ***************以下是EXCEL正文数据********************* */
		   int rowNo = 1;
		   for(T obj: contents){
			   writingHandler.write(obj, rowNo, sheet, wcf_left);
			   rowNo++;
		   }
		   /** **********将以上缓存中的内容写到EXCEL文件中******** */
		   workbook.write();
		   /** *********关闭文件************* */
		   workbook.close();   

	  } catch (Exception e) {
		  e.printStackTrace();
	      return false;
	  } 
	  return true;
 }
 
开发者ID:shuqin,项目名称:ALLIN,代码行数:59,代码来源:ExcelUtils.java

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

示例14: exportExcel

import jxl.write.WritableCellFormat; //导入方法依赖的package包/类
public static void exportExcel(String name, String[] head,
		String[][] content) throws Exception {
	// FileChooser
	JFileChooser chooser = new JFileChooser();
	chooser.setFileSelectionMode(JFileChooser.SAVE_DIALOG
			| JFileChooser.DIRECTORIES_ONLY);
	chooser.showDialog(null, null);
	File fi = chooser.getSelectedFile();
	if (fi == null) {
		return;
	} else {
		String f = fi.getAbsolutePath() + "/" + name;
		File file = new File(f);
		if (!file.exists()) {
			file.createNewFile();
		}

		WritableWorkbook book = Workbook.createWorkbook(file);
		WritableSheet sheet = book.createSheet("第一页", 0);
		SheetSettings setting = sheet.getSettings();
		setting.setVerticalFreeze(1);

		// 第一行字体
		WritableFont headFont = new WritableFont(
				WritableFont.createFont("微软雅黑"), 10, WritableFont.BOLD);
		WritableCellFormat headF = new WritableCellFormat(headFont);
		headF.setAlignment(Alignment.CENTRE); // 平行居中
		headF.setVerticalAlignment(VerticalAlignment.CENTRE); // 垂直居中

		// 表格内容字体
		WritableFont contentFont = new WritableFont(
				WritableFont.createFont("微软雅黑"), 9, WritableFont.NO_BOLD);
		WritableCellFormat contentF = new WritableCellFormat(contentFont);
		contentF.setAlignment(Alignment.CENTRE); // 平行居中
		contentF.setVerticalAlignment(VerticalAlignment.CENTRE); // 垂直居中

		int column = head.length;
		// 不包括头
		int row = content.length;

		for (int i = 0; i < column; i++)
			sheet.addCell(new Label(i, 0, head[i], headF));
		for (int i = 0; i < row; i++)
			for (int j = 0; j < column; j++)
				sheet.addCell(new Label(j, i + 1, content[i][j], contentF));

		book.write();
		book.close();

		 JOptionPane.showMessageDialog(null, "导出excel成功辣!", "提示",
		 JOptionPane.CLOSED_OPTION);
	}

}
 
开发者ID:Disguiser-w,项目名称:SE2,代码行数:55,代码来源:FileExporter.java


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