當前位置: 首頁>>代碼示例>>Java>>正文


Java HSSFSheet.getPhysicalNumberOfRows方法代碼示例

本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFSheet.getPhysicalNumberOfRows方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFSheet.getPhysicalNumberOfRows方法的具體用法?Java HSSFSheet.getPhysicalNumberOfRows怎麽用?Java HSSFSheet.getPhysicalNumberOfRows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.hssf.usermodel.HSSFSheet的用法示例。


在下文中一共展示了HSSFSheet.getPhysicalNumberOfRows方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readExcel

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
public static void readExcel(String filePth) throws Exception {
	InputStream is = new FileInputStream(filePth);
	//創建工作薄
	//XSSFWorkbook hwb = new XSSFWorkbook(is);
	HSSFWorkbook hwb = new HSSFWorkbook(new POIFSFileSystem(is));
	//得到sheet
	for (int i = 0; i < hwb.getNumberOfSheets(); i++) {
		HSSFSheet sheet = hwb.getSheetAt(i);
		int rows = sheet.getPhysicalNumberOfRows();
		//遍曆每一行
		for (int j = 0; j < rows; j++) {
			HSSFRow hr = sheet.getRow(j);
			Iterator<?> it = hr.iterator();
			while(it.hasNext()){
				String context = it.next().toString();
				System.out.println(context);
			}
		}
	}
	hwb.close();
}
 
開發者ID:tank2140896,項目名稱:JavaWeb,代碼行數:22,代碼來源:FileUtil.java

示例2: buildMaxColumn

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
private int buildMaxColumn(HSSFSheet sheet){
	int rowCount=sheet.getPhysicalNumberOfRows();
	int maxColumnCount=0;
	for(int i=0;i<rowCount;i++){
		HSSFRow row=sheet.getRow(i);
		if(row==null){
			continue;
		}
		int columnCount=row.getPhysicalNumberOfCells();
		if(columnCount>maxColumnCount){
			maxColumnCount=columnCount;
		}
	}
	return maxColumnCount;
}
 
開發者ID:youseries,項目名稱:ureport,代碼行數:16,代碼來源:HSSFExcelParser.java

示例3: readExcel2003

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
public static ArrayList<ArrayList<ArrayList<Object>>> readExcel2003(File file){
	try{
		ArrayList<ArrayList<ArrayList<Object>>> sheetArray = new ArrayList<ArrayList<ArrayList<Object>>> ();
		HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(file));
		for(int sheetNum = 0;sheetNum < wb.getNumberOfSheets();sheetNum++){
			ArrayList<ArrayList<Object>> rowList = new ArrayList<ArrayList<Object>>();
			ArrayList<Object> colList;
			HSSFSheet sheet = wb.getSheetAt(sheetNum);
			HSSFRow row;
			HSSFCell cell;
			Object value;
			for(int i = 0 , rowCount = 0; rowCount < sheet.getPhysicalNumberOfRows() ; i++ ){
				row = sheet.getRow(i);
				colList = new ArrayList<Object>();
				if(row == null){
					//����ȡ��Ϊ��ʱ
					if(i != sheet.getPhysicalNumberOfRows()){//�ж��Ƿ������һ��
						rowList.add(colList);
					}
					continue;
				}else{
					rowCount++;
				}
				for( int j = 0 ; j <= row.getLastCellNum() ;j++){
					cell = row.getCell(j);
					if(cell == null ){
						//���õ�Ԫ��Ϊ��
						if(j != row.getLastCellNum()){//�ж��Ƿ��Ǹ��������һ����Ԫ��
							colList.add("");
						}
						continue;
					}
					switch(cell.getCellType()){
					 case XSSFCell.CELL_TYPE_STRING:  
		                    value = cell.getStringCellValue();  
		                    break;  
		                case XSSFCell.CELL_TYPE_NUMERIC:  
		                    if ("@".equals(cell.getCellStyle().getDataFormatString())) {  
		                        value = df.format(cell.getNumericCellValue());  
		                    } else if ("General".equals(cell.getCellStyle()  
		                            .getDataFormatString())) {  
		                        value = nf.format(cell.getNumericCellValue());  
		                    } else {  
		                        value = sdf.format(HSSFDateUtil.getJavaDate(cell  
		                                .getNumericCellValue()));  
		                    }  
		                    break;  
		                case XSSFCell.CELL_TYPE_BOOLEAN:  
		                    value = Boolean.valueOf(cell.getBooleanCellValue());
		                    break;  
		                case XSSFCell.CELL_TYPE_BLANK:  
		                    value = "";  
		                    break;  
		                default:  
		                    value = cell.toString();  
					}// end switch
					colList.add(value);
				}//end for j
				rowList.add(colList);
			}//end for i
			sheetArray.add(rowList);
		}// end sheetNum
		
		return sheetArray;
	}catch(Exception e){
		return null;
	}
}
 
開發者ID:sqyNick,項目名稱:JavaUtils,代碼行數:69,代碼來源:ExcelUtil.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFSheet.getPhysicalNumberOfRows方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。