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


Java HSSFRow.createCell方法代码示例

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


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

示例1: makeHeader

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
private void makeHeader ( final List<Field> columns, final HSSFSheet sheet )
{
    final Font font = sheet.getWorkbook ().createFont ();
    font.setFontName ( "Arial" );
    font.setBoldweight ( Font.BOLDWEIGHT_BOLD );
    font.setColor ( HSSFColor.WHITE.index );

    final CellStyle style = sheet.getWorkbook ().createCellStyle ();
    style.setFont ( font );
    style.setFillForegroundColor ( HSSFColor.BLACK.index );
    style.setFillPattern ( PatternFormatting.SOLID_FOREGROUND );

    final HSSFRow row = sheet.createRow ( 0 );

    for ( int i = 0; i < columns.size (); i++ )
    {
        final Field field = columns.get ( i );

        final HSSFCell cell = row.createCell ( i );
        cell.setCellValue ( field.getHeader () );
        cell.setCellStyle ( style );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:ExportEventsImpl.java

示例2: insertItemToSheet

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
private void insertItemToSheet(String table, HSSFSheet sheet, ArrayList<String> columns) {
    HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
    Cursor cursor = database.rawQuery("select * from " + table, null);
    cursor.moveToFirst();
    int n = 1;
    while (!cursor.isAfterLast()) {
        HSSFRow rowA = sheet.createRow(n);
        for (int j = 0; j < columns.size(); j++) {
            HSSFCell cellA = rowA.createCell(j);
            if (cursor.getType(j) == Cursor.FIELD_TYPE_BLOB) {
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) j, n, (short) (j + 1), n + 1);
                anchor.setAnchorType(3);
                patriarch.createPicture(anchor, workbook.addPicture(cursor.getBlob(j), HSSFWorkbook.PICTURE_TYPE_JPEG));
            } else {
                cellA.setCellValue(new HSSFRichTextString(cursor.getString(j)));
            }
        }
        n++;
        cursor.moveToNext();
    }
    cursor.close();
}
 
开发者ID:androidmads,项目名称:SQLite2XL,代码行数:23,代码来源:SQLiteToExcel.java

示例3: writeXLSFile

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
public static void writeXLSFile() throws IOException {

			HSSFWorkbook wbObj = new HSSFWorkbook();
			HSSFSheet sheet = wbObj.createSheet(sheetName);

			for (int row = 0; row < tableData.size(); row++) {
				HSSFRow rowObj = sheet.createRow(row);
				rowData = tableData.get(row);
				for (int col = 0; col < rowData.size(); col++) {
					HSSFCell cellObj = rowObj.createCell(col);
					cellObj.setCellValue(rowData.get(col));
				}
			}

			FileOutputStream fileOut = new FileOutputStream(excelFileName);
			wbObj.write(fileOut);
			wbObj.close();
			fileOut.flush();
			fileOut.close();
		}
 
开发者ID:sergueik,项目名称:SWET,代码行数:21,代码来源:TableEditorEx.java

示例4: createColumnHeaders

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
/**
 */
protected void createColumnHeaders() {
	final HSSFRow headersRow = this.sheet.createRow(0);
	final HSSFFont font = this.workbook.createFont();
	font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
	final HSSFCellStyle style = this.workbook.createCellStyle();
	style.setFont(font);
	style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	int counter = 1;
	for (int i = 0; i < this.model.getColumnCount(); i++) {
		final HSSFCell cell = headersRow.createCell(counter++);
		// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
		cell.setCellValue(this.model.getColumnName(i));
		cell.setCellStyle(style);
	}
}
 
开发者ID:kiswanij,项目名称:jk-util,代码行数:18,代码来源:JKExcelUtil.java

示例5: createContent

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
public void createContent(WebInput wi, DocInfo di)throws ControllerException {
	HSSFWorkbook wb = di.getExcelDocument();
	// 创建HSSFSheet对象
	HSSFSheet sheet = wb.createSheet("sheet0");
	// 创建HSSFRow对象
	HSSFRow row = sheet.createRow((short) 0);
	// 创建HSSFCell对象
	HSSFCell cell = row.createCell((short) 0);
	// 用来处理中文问题
	// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
	// 设置单元格的值
	// cell.setCellValue("Hello World! 你好,中文世界");
	String info = wi.getParameter("info");
	HSSFRichTextString rts = new HSSFRichTextString(info);
	cell.setCellValue(rts);
	HSSFCell cell2 = row.createCell((short) 1);
	cell2.setCellValue(new HSSFRichTextString(
			"Beetle Web Framework 页面生成Excel文件演示!"));
}
 
开发者ID:jbeetle,项目名称:BJAF3.x,代码行数:20,代码来源:GenExcelController.java

示例6: writeBody

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
void writeBody(HSSFSheet sheet){
		Set<String> keySet = getColumnJson().keySet();
		List<T> ts = getData();
		for (T t:ts) {
//			Class cls = t.getClass();
			int cellNumber = 0;//将cellNumber从0开始
			HSSFRow row = sheet.createRow(addRowNumber());//创建新的一行
			for(String key:keySet){
				try {
					HSSFCell cell = row.createCell(cellNumber++);
					Object value = getValueByKey(t, key);
					setCellValue(cell, value);
					pubMaxValue(key, value);
				} catch (Exception e) {
					throw new RuntimeException("writeBody", e);
				}
			}
		}
	}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:20,代码来源:ExcelExportSuper.java

示例7: createHeader

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
private boolean createHeader(WorkbookGeneratorContext context,
                            HSSFSheet sheet,
                            HSSFCellStyle style) {
    if (context.headerNames == null || context.headerNames.isEmpty()) {
        return false;
    }

    int headerRowIndex = 0;
    HSSFRow rowHeader = sheet.createRow(headerRowIndex);
    for (int i = 0; i < context.headerNames.size(); i++) {
        HSSFCell cell = rowHeader.createCell(i);
        sheet.autoSizeColumn((short) i);

        cell.setCellStyle(style);
        cell.setCellValue(new HSSFRichTextString(context.headerNames.get(i)));
    }
    return true;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:19,代码来源:PoiWorkbookGeneratorStrategy.java

示例8: writeDirectTestData

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
@Override
protected void writeDirectTestData(final ERTable table, final Map<NormalColumn, String> data, final String database) {
    final HSSFRow row = sheet.createRow(rowNum++);

    int col = 0;

    for (final NormalColumn column : table.getExpandedColumns()) {
        final HSSFCell cell = row.createCell(col++);

        final String value = Format.null2blank(data.get(column));

        if (value == null || "null".equals(value.toLowerCase())) {

        } else {
            cell.setCellValue(new HSSFRichTextString(value));
        }
    }
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:19,代码来源:DBUnitXLSTestDataCreator.java

示例9: write

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
public void write(String src) throws IOException{
  
  System.out.println(src);
  HSSFWorkbook wb = new HSSFWorkbook();
  HSSFSheet sheet = wb.createSheet("Resultats");
  
  for (int i=0; i<size(); i++) {
    HSSFRow row = sheet.createRow(i);
    HSSFCell cell = row.createCell(0);
    cell.setCellValue(get(i).area());
  }
  
  
  FileOutputStream fileOut;
    fileOut = new FileOutputStream(src);
    wb.write(fileOut);
    fileOut.close();
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:19,代码来源:VectPolygon.java

示例10: writeCondtions

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
/**
 * 表头条件
 * @param sheet
 * @param t
 * @param cellCount
 * @return
 */
void writeCondtions(HSSFSheet sheet){
	T t = getConditions();
	if (t!=null) {
		HSSFRow row = sheet.createRow(getRowNumber());
		row.setHeight((short) 500);
		CellRangeAddress cra = new CellRangeAddress(getRowNumber(), getRowNumber(), 0, getColumnJson().size());
		sheet.addMergedRegion(cra);
		HSSFCell cell = row.createCell(0);
		HSSFCellStyle style = cell.getCellStyle();
		style.setAlignment(HorizontalAlignment.CENTER);
		style.setVerticalAlignment(VerticalAlignment.CENTER);
		style.setWrapText(true);
		cell.setCellStyle(style);
		setCellValue(cell, formatCondition(t));
		addRowNumber();
	}
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:25,代码来源:ExcelExportSuper.java

示例11: test_001

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
@Test
public void test_001()
{
    HSSFWorkbook v_Workbook = new HSSFWorkbook();
    HSSFSheet    v_Sheet    = v_Workbook.createSheet("测试单元格颜色");
    
    v_Sheet.setColumnWidth(0 ,2560);
    
    for (int v_RowIndex=0; v_RowIndex<4000; v_RowIndex++)
    {
        HSSFRow v_Row = v_Sheet.createRow(v_RowIndex);
        
        for (int v_ColIndex=0; v_ColIndex<1; v_ColIndex++)
        {
            HSSFCell      v_Cell = v_Row.createCell(v_ColIndex);
            HSSFCellStyle v_CellStyle = v_Workbook.createCellStyle();
            
            v_CellStyle.setFillForegroundColor((short)(v_RowIndex + 1));
            v_CellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
            
            v_Cell.setCellStyle(v_CellStyle);
            v_Cell.setCellValue("" + (v_RowIndex + 1));
        }
    }
    
    ExcelHelp.save(v_Workbook ,"/Users/hy/Downloads/测试2003版本的单元格颜色");
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:28,代码来源:JU_Excel2003Color.java

示例12: createSheet

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
private void createSheet(String table, HSSFSheet sheet) {
    HSSFRow rowA = sheet.createRow(0);
    ArrayList<String> columns = getColumns(table);
    for (int i = 0; i < columns.size(); i++) {
        HSSFCell cellA = rowA.createCell(i);
        cellA.setCellValue(new HSSFRichTextString("" + columns.get(i)));
    }
    insertItemToSheet(table, sheet, columns);
}
 
开发者ID:androidmads,项目名称:SQLite2XL,代码行数:10,代码来源:SQLiteToExcel.java

示例13: writeTableHeader

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
@Override
protected void writeTableHeader(final ERDiagram diagram, final ERTable table) {
    final String sheetName = table.getPhysicalName();
    sheet = workbook.createSheet(sheetName);

    rowNum = 0;
    final HSSFRow row = sheet.createRow(rowNum++);

    int col = 0;

    for (final NormalColumn column : table.getExpandedColumns()) {
        final HSSFCell cell = row.createCell(col++);
        cell.setCellValue(new HSSFRichTextString(column.getPhysicalName()));
    }
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:16,代码来源:DBUnitXLSTestDataCreator.java

示例14: createHeader

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
private void createHeader(
		HSSFWorkbook wb,
		HSSFSheet sheet,
		List<TascaDadaDto> informeCamps) {
	HSSFFont bold;
	bold = wb.createFont();
	bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
	bold.setColor(HSSFColor.WHITE.index);
	HSSFCellStyle headerStyle;
	headerStyle = wb.createCellStyle();
	headerStyle.setFillPattern(HSSFCellStyle.FINE_DOTS);
	headerStyle.setFillBackgroundColor(HSSFColor.GREY_80_PERCENT.index);
	headerStyle.setFont(bold);
	int rowNum = 0;
	int colNum = 0;
	// Capçalera
	HSSFRow xlsRow = sheet.createRow(rowNum++);
	HSSFCell cell;
	cell = xlsRow.createCell(colNum++);
	cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize("Expedient")));
	cell.setCellStyle(headerStyle);
	for (TascaDadaDto camp : informeCamps) {
		sheet.autoSizeColumn(colNum);
		cell = xlsRow.createCell(colNum++);
		cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize(camp.getCampEtiqueta())));
		cell.setCellStyle(headerStyle);
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:29,代码来源:ExpedientConsultaInformeController.java

示例15: getCell

import org.apache.poi.hssf.usermodel.HSSFRow; //导入方法依赖的package包/类
/**
 * Convenient method to obtain the cell in the given sheet, row and column.
 * <p>Creates the row and the cell if they still doesn't already exist.
 * Thus, the column can be passed as an int, the method making the needed downcasts.
 * @param sheet a sheet object. The first sheet is usually obtained by workbook.getSheetAt(0)
 * @param row the row number
 * @param col the column number
 * @return the HSSFCell
 */
protected HSSFCell getCell(HSSFSheet sheet, int row, int col) {
	HSSFRow sheetRow = sheet.getRow(row);
	if (sheetRow == null) {
		sheetRow = sheet.createRow(row);
	}
	HSSFCell cell = sheetRow.getCell(col);
	if (cell == null) {
		cell = sheetRow.createCell(col);
	}
	return cell;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:AbstractExcelView.java


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