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


Java Row类代码示例

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


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

示例1: testDown

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
@RequestMapping(value = "/test2.xlsx", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
byte[] testDown() throws IOException, InvalidFormatException {
    Workbook workbook = new SXSSFWorkbook();
    Sheet sheet = workbook.createSheet();
    for (int i = 0; i < 60000; i++) {
        Row newRow = sheet.createRow(i);
        for (int j = 0; j < 100; j++) {
            newRow.createCell(j).setCellValue("test" + Math.random());
        }
    }
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    workbook.write(os);
    byte[] bytes = os.toByteArray();
    return bytes;
}
 
开发者ID:Yuiffy,项目名称:file-download-upload-zip-demo,代码行数:17,代码来源:FileController.java

示例2: readExcelFile

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
/**
 * Método que se encarga de leer el libro de excel
 * cuya ruta recibimos en el constructor y devuelve una lista 
 * de ciudadanos
 * @return lista de Usuarios de la base de datos
 */
public List<CitizenDB> readExcelFile(){
	List<CitizenDB> citizens = new ArrayList<CitizenDB>(); 
	// para cada una de las hojas presentes en el documento de excel
	for(int i=0;i < workbook.getNumberOfSheets();i++){
		XSSFSheet sheet = this.workbook.getSheetAt(i);
		Iterator<Row> rowIterator = sheet.iterator();
		Row row;
		int counter = 0;
		//para cada fila de la hoja
		while(rowIterator.hasNext()){
			row = rowIterator.next();
			if (counter > 0) { //omitimos la cabecera (hay que mirar si hay un metodo de la API)
				Iterator<Cell> cellIterator = row.cellIterator();
				int j = 0;
				CitizenDB user = new CitizenDB();
				while (cellIterator.hasNext()) 	
					this.insertCitizenField(user, j++, cellIterator.next());	
				user.setPassword(new GenerationPassword().passwordGenerator());
				citizens.add(user);
			}
			counter++;
		}
	}
	return citizens;
}
 
开发者ID:Arquisoft,项目名称:dashboard1b,代码行数:32,代码来源:AdapterPoi.java

示例3: doCreateSheetSingleHeadRow

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
/** 创建不需要合并单元格的表头
 * @param fieldInfoMap
 * @param headCellStyleMap
 * @param row
 * @param fieldList
 * @param cellNum
 */
private static void doCreateSheetSingleHeadRow(Map<Field, ExportFieldInfo> fieldInfoMap,
		Map<Field, CellStyle> headCellStyleMap, Row row, List<SortableField> fieldList, int cellNum) {
	
	Cell cell;
	String value;
	for(int i = 0 ; i < fieldList.size() ; i++ , cellNum++){
		Field field = fieldList.get(i).getField();
		value = fieldInfoMap.get(field).getHeadName();
		cell = row.createCell(cellNum);
		cell.setCellValue(value);
		if( headCellStyleMap != null && headCellStyleMap.get(field) != null ){
			cell.setCellStyle(headCellStyleMap.get(field));
		}
	}
}
 
开发者ID:long47964,项目名称:excel-utils,代码行数:23,代码来源:ExcelExportUtil.java

示例4: print

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
public void print () {
	Sheet sheet =  getOrCreateSummary();
	Iterator<Row> rows = sheet.rowIterator();
	int index=0;
	while (rows.hasNext()) {
		Row row = (Row) rows.next();
		System.out.println("Row ---> " + index);
		Spliterator<Cell> cells = row.spliterator();
		cells.forEachRemaining(new Consumer<Cell> () {
			@Override
			public void accept(Cell cell) {
				System.out.print(cell.toString());
				System.out.print(";");
			}
		});
		System.out.println();
		index++;
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:20,代码来源:XLTestSummarySheet.java

示例5: getClasses

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
private List<String> getClasses(Row classRow) {
	//声明一个list,用来存放所有的字段类型
	List<String> classList = new ArrayList<String>();
	//判断这一行是否为空
	if (classRow != null) {
		//遍历这一行的所有单元格
		for (int i = 0; i < classRow.getLastCellNum(); i++) {
			//获取单元格
			Cell cell = classRow.getCell(i);
			//判断单元格是否为空
			if (cell != null) {
				//将单元格的内容存放到list中
				classList.add(cell.getStringCellValue());
			}
		}
	}
	//返回所有的字段类型
	return classList;
}
 
开发者ID:yuchaozxc,项目名称:ExcelToXml,代码行数:20,代码来源:ExcelToXml.java

示例6: setSheetData

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
private void setSheetData(SheetData data, String group) {
	data.setCurrentGroup(group);
	// start from 1
	data.setCurrentIndex(1);
	// get sheet
	Sheet vSheet = getWorkBook().getSheet(group);
	Assert.notNull(vSheet, "Can't get sheet with name: " + group);
	data.setSheet(vSheet);
	// get row number
	int vRowCount = vSheet.getLastRowNum() + 1;
	data.setRowCount(vRowCount);
	// get first row
	Row vRow = vSheet.getRow(0);
	Assert.notNull(vRow, "Invalid format: first row must be title");
	// get column number
	int vColumnCount = vRow.getLastCellNum();
	String[] vTitles = new String[vColumnCount];
	// read titles
	for (int i = 0; i < vColumnCount; ++i) {
		Cell vCell = vRow.getCell(i);
		vTitles[i] = vCell.getStringCellValue();
	}
	data.setTitles(vTitles);
}
 
开发者ID:xinufo,项目名称:teemo,代码行数:25,代码来源:ExcelReader.java

示例7: createWorkBook

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
public static void createWorkBook() throws IOException {
	// ����excel������
	final Workbook wb = new XSSFWorkbook();
	// ����sheet��ҳ��
	final Sheet sheet1 = wb.createSheet("Sheet_1");
	final Sheet sheet2 = wb.createSheet("Sheet_2");

	for (int i = 0; i < 20; i = i + 2) {
		final Row row1 = sheet1.createRow(i);
		final Row row2 = sheet2.createRow(i);

		for (int j = 0; j < 10; j++) {

			row1.createCell(j).setCellValue(j + "new");
			row2.createCell(j).setCellValue(j + "This is a string");

		}
	}
	// ����һ���ļ� ����Ϊworkbooks.xlsx
	final FileOutputStream fileOut = new FileOutputStream("d:\\workbooks.xlsx");
	// �����洴���Ĺ�����������ļ���
	wb.write(fileOut);
	// �ر������
	fileOut.close();
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:26,代码来源:Excel4J.java

示例8: export

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
/**
 * Exports a single sheet to a file
 *
 * @param sheet
 * @throws FactoryConfigurationError
 * @throws XMLStreamException
 * @throws UnsupportedEncodingException
 * @throws FileNotFoundException
 */
private void export(final XSSFSheet sheet, final XMLStreamWriter out)
		throws UnsupportedEncodingException, XMLStreamException, FactoryConfigurationError, FileNotFoundException {
	boolean isFirst = true;
	final Map<String, String> columns = new HashMap<String, String>();
	final String sheetName = sheet.getSheetName();
	System.out.print(sheetName);
	out.writeStartElement("sheet");
	out.writeAttribute("name", sheetName);
	Iterator<Row> rowIterator = sheet.rowIterator();
	while (rowIterator.hasNext()) {
		Row row = rowIterator.next();
		if (isFirst) {
			isFirst = false;
			this.writeFirstRow(row, out, columns);
		} else {
			this.writeRow(row, out, columns);
		}
	}
	out.writeEndElement();
	System.out.println("..");
}
 
开发者ID:Stwissel,项目名称:Excel2XML,代码行数:31,代码来源:E2xCmdline.java

示例9: parseRow

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
/**
 * 解析行
 * @param row
 * @return
 */
protected List<Object> parseRow(Row row) {
	List<Object> rowData = new ArrayList<Object>();

	for (int i = 0; i < row.getLastCellNum(); i++) {
		Cell cell = row.getCell(i);
		Object cellObj=null;
		if(cell!=null){
			cellObj = parseCell(cell);
		}
		rowData.add(cellObj);
	}
	/*// 迭代 一行的各个单元格
	Iterator<Cell> cellIterator = row.iterator();
	// 遍历一行多列
	while (cellIterator.hasNext()) {
		Cell cell = cellIterator.next();
		Object cellObj = parseCell(cell);
		rowData.add(cellObj);
	}*/
	return rowData;
}
 
开发者ID:babymm,项目名称:mumu,代码行数:27,代码来源:ExcelParser.java

示例10: unmarshal

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
public <T> List<T> unmarshal(Class<T> type) {
    Workbook workbook = poijiWorkbook.workbook();
    Sheet sheet = workbook.getSheetAt(options.sheetIndex());

    int skip = options.skip();
    int maxPhysicalNumberOfRows = sheet.getPhysicalNumberOfRows() + 1 - skip;
    List<T> list = new ArrayList<>(maxPhysicalNumberOfRows);

    for (Row currentRow : sheet) {

        if (skip(currentRow, skip))
            continue;

        if (isRowEmpty(currentRow))
            continue;

        if (maxPhysicalNumberOfRows > list.size()) {
            T t = deserialize0(currentRow, type);
            list.add(t);
        }
    }

    return list;
}
 
开发者ID:ozlerhakan,项目名称:poiji,代码行数:25,代码来源:HSSFUnmarshaller.java

示例11: writeTitlePageHeader

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
/**
 * 按报表模板格式写分页页眉标题
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-06-25
 * @version     v1.0
 *
 * @param i_DataWorkbook   数据工作薄
 * @param i_DataSheet      数据工作表
 * @param io_RTotal        将数据写入Excel时的辅助统计信息
 * @param io_RSystemValue  系统变量信息
 * @param i_Datas          数据
 * @param i_RTemplate      报表模板对象
 */
public final static void writeTitlePageHeader(RWorkbook i_DataWorkbook ,Sheet i_DataSheet ,RTotal io_RTotal ,RSystemValue io_RSystemValue ,Object i_Datas ,RTemplate i_RTemplate) 
{
    Sheet v_TemplateSheet    = i_RTemplate.getTemplateSheet();
    int   v_TemplateRowCount = io_RTotal.getTitlePageHeaderCount();
    int   v_ExcelRowIndex    = io_RTotal.getExcelRowIndex();

    copyMergedRegionsTitlePageHeader(i_RTemplate ,i_DataSheet ,io_RTotal);  // 按模板合并单元格
    copyImagesTitlePageHeader(       i_RTemplate ,i_DataSheet ,io_RTotal);  // 按模板复制图片
    
    io_RSystemValue.setPageNo(io_RSystemValue.getPageNo() + 1);
    
    for (int v_RowNo=0; v_RowNo<v_TemplateRowCount; v_RowNo++)
    {
        int v_TemplateRowNo = i_RTemplate.getTitlePageHeaderBeginRow() + v_RowNo;
        Row v_TemplateRow   = v_TemplateSheet.getRow(v_TemplateRowNo);
        
        int v_DataRowNo = v_RowNo + v_ExcelRowIndex;
        Row v_DataRow   = i_DataSheet.createRow(v_DataRowNo);
        io_RTotal.addExcelRowIndex(1);
        
        copyRow(i_RTemplate ,v_TemplateRow ,i_DataWorkbook ,io_RTotal ,io_RSystemValue ,v_DataRow ,i_Datas);
    }
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:38,代码来源:JavaToExcel.java

示例12: main

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
public static void main(String[] args) throws Throwable {
        SXSSFWorkbook wb = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk
        Sheet sh = wb.createSheet();
        for (int rownum = 0; rownum < 1000; rownum++) {
            Row row = sh.createRow(rownum);
            Row row1 = sh.createRow(rownum);
            for (int cellnum = 0; cellnum < 10; cellnum++) {
                Cell cell = row.createCell(cellnum);
                String address = new CellReference(cell).formatAsString();
                cell.setCellValue(address);
            }

        }

        // Rows with rownum < 900 are flushed and not accessible
//        for (int rownum = 0; rownum < 103857; rownum++) {
//            Assert.assertNull(sh.getRow(rownum));
//        }
//
//        // ther last 100 rows are still in memory
//        for (int rownum = 103857; rownum < 104857; rownum++) {
//            Assert.assertNotNull(sh.getRow(rownum));
//        }

        File file = new File("C:\\Users\\FlyingHe\\Desktop", "datas.xlsx");
        FileOutputStream out = new FileOutputStream(file);
        wb.write(out);
        out.close();

        // dispose of temporary files backing this workbook on disk
        wb.dispose();
    }
 
开发者ID:FlyingHe,项目名称:UtilsMaven,代码行数:33,代码来源:Example.java

示例13: writeRow

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
private void writeRow(final Row row, final XMLStreamWriter out, final Map<String, String> columns) {
	try {
		int rowIndex = row.getRowNum();
		out.writeStartElement("row");
		final String rowNum = String.valueOf(rowIndex);
		out.writeAttribute("row", rowNum);
		int count = 0;
		Iterator<Cell> cellIterator = row.iterator();
		while (cellIterator.hasNext()) {
			Cell cell = cellIterator.next();
			int columnIndex = cell.getColumnIndex();
			if (this.exportEmptyCells) {
				while (count < columnIndex) {
					this.writeAnyCell(rowIndex, count, null, out, columns);
					count++;
				}
			}
			this.writeCell(cell, out, columns);
			count++;
		}
		out.writeEndElement();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}

}
 
开发者ID:Stwissel,项目名称:Excel2XML,代码行数:27,代码来源:E2xCmdline.java

示例14: writeTotal

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
/**
 * 按报表模板格式写入合计(暂时不支持分页功能)
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-03-18
 * @version     v1.0
 *
 * @param i_DataWorkbook   数据工作薄
 * @param i_DataSheet      数据工作表
 * @param io_RTotal        将数据写入Excel时的辅助统计信息
 * @param io_RSystemValue  系统变量信息
 * @param i_Datas          数据
 * @param i_RTemplate      报表模板对象
 */
public final static void writeTotal(RWorkbook i_DataWorkbook ,Sheet i_DataSheet ,RTotal io_RTotal ,RSystemValue io_RSystemValue, Object i_Datas ,RTemplate i_RTemplate) 
{
    Sheet v_TemplateSheet         = i_RTemplate.getTemplateSheet();
    int   v_TemplateRowCountTotal = i_RTemplate.getRowCountTotal();
    int   v_ExcelRowIndex         = io_RTotal.getExcelRowIndex();
    
    copyMergedRegionsTotal(i_RTemplate ,i_DataSheet ,io_RTotal);  // 按模板合并单元格
    copyImagesTotal(       i_RTemplate ,i_DataSheet ,io_RTotal);  // 按模板复制图片
    
    for (int v_RowNo=0; v_RowNo<v_TemplateRowCountTotal; v_RowNo++) 
    {
        int v_TemplateRowNo = i_RTemplate.getTotalBeginRow() + v_RowNo;
        Row v_TemplateRow   = v_TemplateSheet.getRow(v_TemplateRowNo);
        
        int v_DataRowNo = v_RowNo + v_ExcelRowIndex;
        Row v_DataRow   = i_DataSheet.createRow(v_DataRowNo);
        io_RTotal.addExcelRowIndex(1);
        io_RTotal.addRealDataCount(1);
        
        copyRow(i_RTemplate ,v_TemplateRow ,i_DataWorkbook ,io_RTotal ,io_RSystemValue ,v_DataRow ,i_Datas);
    }
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:37,代码来源:JavaToExcel.java

示例15: CommentWriter

import org.apache.poi.ss.usermodel.Row; //导入依赖的package包/类
public CommentWriter(OutputStream outputStream) throws IOException{
    this.outputStream = outputStream;

    this.workbook = new XSSFWorkbook();
    this.sheet = workbook.createSheet("Comments");

    Row row = sheet.createRow(0);
    Cell cell = row.createCell(0);
    cell.setCellValue("#");

    cell = row.createCell(1);
    cell.setCellValue("comment");

    cell = row.createCell(2);
    cell.setCellValue("timestamp");

    rowCount = 1;
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-3-sixguysburgers-fries,代码行数:19,代码来源:CommentWriter.java


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