當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。