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


Java CellReference.getRow方法代碼示例

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


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

示例1: getEmptyRow

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public static int getEmptyRow(Workbook wb, int sheetIndex, String cellRef) {
	final Sheet sheet = wb.getSheetAt(sheetIndex);
	final CellReference cellReference = new CellReference(cellRef); // һ����A1
	boolean flag = false;
	for (int i = cellReference.getRow(); i <= sheet.getLastRowNum();) {
		final Row r = sheet.getRow(i);
		if (r == null) {
			// ����ǿ��У���û���κ����ݡ���ʽ����ֱ�Ӱ������µ����������ƶ�
			sheet.shiftRows(i + 1, sheet.getLastRowNum(), -1);
			continue;
		}
		flag = false;
		for (final Cell c : r) {
			if (c.getCellType() != Cell.CELL_TYPE_BLANK) {
				flag = true;
				break;
			}
		}
		if (flag) {
			i++;
			continue;
		} else {// ����ǿհ��У�������û�����ݣ�������һ����ʽ��
			if (i == sheet.getLastRowNum())// ����������һ�У�ֱ�ӽ���һ��remove��
				sheet.removeRow(r);
			else// �����û�����һ�У�������������һ��
				sheet.shiftRows(i + 1, sheet.getLastRowNum(), -1);
		}
	}
	return sheet.getLastRowNum() + 1;
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:31,代碼來源:ExcelOperation.java

示例2: fromA1Address

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public static A1Address fromA1Address(String a1address) {
    //check in pool
    A1Address address = A1AddressPool.get(a1address);
    if (address != null) { return address; }
    
    //check if range
    if (isRange(a1address)) { return new A1RangeAddress(a1address); }
    
    //create
    A1Address a = new A1Address();
    a.address = a1address;

    CellReference cr = new CellReference(a.address);
    a.row = cr.getRow();
    a.column = cr.getCol();

    return a;
}
 
開發者ID:DataArt,項目名稱:CalculationEngine,代碼行數:19,代碼來源:A1Address.java

示例3: isReferenceValid

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public boolean isReferenceValid(CellReference ref) {
    if(ref == null)
        return false;
    
    String sheet = ref.getSheetName();
    if(sheet == null || sheet.length()==0 || !sheets.contains(sheet))
        return false;
    
    if(ref.getCol() >= getMaxCol())
        return false;
    
    if(ref.getRow() >= getMaxRow())
        return false;
    
    return true;
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:17,代碼來源:ReferenceUtil.java

示例4: getXY

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public final static int[] getXY(String xy) {
	xy = xy.trim();
	if (StringUtils.isEmpty(xy)) {
		return new int[] { -1, -1 };
	}
	if (!StringUtils.isAlphanumeric(xy)) {
		return null;
	}
	CellReference ref = new CellReference(xy);
	return new int[] { ref.getRow() < 0 ? -1 : ref.getRow(), ref.getCol() < 0 ? -1 : ref.getCol() };
}
 
開發者ID:niuxuetao,項目名稱:paxml,代碼行數:12,代碼來源:ExcelRange.java

示例5: getXY

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
protected int[] getXY(String xy) {
	xy = xy.trim();
	if (StringUtils.isEmpty(xy)) {
		return new int[] { -1, -1 };
	}
	if (!StringUtils.isAlphanumeric(xy)) {
		return null;
	}
	CellReference ref = new CellReference(xy);
	return new int[] { ref.getRow() < 0 ? -1 : ref.getRow(), ref.getCol() < 0 ? -1 : ref.getCol() };
}
 
開發者ID:niuxuetao,項目名稱:paxml,代碼行數:12,代碼來源:ReadExcelTag.java

示例6: parseCellAddress

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
 * Excelのアドレス形式'A1'を、Pointに変換する。
 * @param address
 * @return 変換できない場合は、nullを返す。
 */
public static Point parseCellAddress(final String address) {
    
    if(isEmpty(address)) {
        return null;
    }
    
    final Matcher matcher = PATTERN_CELL_ADREESS.matcher(address);
    if(!matcher.matches()) {
        return null;
    }
    
    final CellReference ref = new CellReference(address.toUpperCase());
    return new Point(ref.getCol(), ref.getRow());
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:20,代碼來源:Utils.java

示例7: toPointAddress

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
 * 文字列の形式のセルのアドレスを、Point形式に変換する。
 * @param address
 * @return
 */
public static Point toPointAddress(final String address) {
    ArgUtils.notEmpty(address, "address");
    
    CellReference ref = new CellReference(address);
    return new Point(ref.getCol(), ref.getRow());
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:12,代碼來源:TestUtils.java

示例8: isOverlapped

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public boolean isOverlapped(Name name) {
	String ref = name.getRefersToFormula();
	int idx = ref.indexOf('!');
	if (idx != -1) {
		ref = ref.substring(idx + 1);
	}
	AreaReference area = new AreaReference(ref);
	CellReference topLeft = area.getFirstCell();
	CellReference bottomRight = area.getLastCell();
	CellRangeAddress cra = new CellRangeAddress(
		topLeft.getRow(), bottomRight.getRow(), 
		topLeft.getCol(), bottomRight.getCol()
	);
	return isOverlapped(cra);
}
 
開發者ID:shunjikonishi,項目名稱:excel2canvas,代碼行數:16,代碼來源:InputRule.java

示例9: getValidCellReference

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public static CellReference getValidCellReference(Workbook wb, String ref) {
    CellReference cr = getCellReference(wb, ref);
    String shName = cr.getSheetName();
    if(shName == null || wb.getSheetIndex(shName) < 0 || 
            cr.getRow() < 0 || cr.getCol() < 0)
        return null;
    return cr;
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:9,代碼來源:ExcelUtil.java

示例10: XlsxTableReader

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public XlsxTableReader(CellReference ref, TableFactory<T> factory) {
    this.factory = factory;
    sheetName = ref.getSheetName();
    firstRow = ref.getRow();
    prevRow = firstRow;
    firstColumn = ref.getCol();
    prevColumn = firstColumn;
    lastColumn = firstColumn;
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:10,代碼來源:XlsxTableReader.java

示例11: XlsTableReader

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public XlsTableReader(CellReference ref, TableFactory<T> factory) {
    this.factory = factory;
    sheetName = ref.getSheetName();
    firstRow = ref.getRow();
    firstColumn = ref.getCol();
    lastColumn = firstColumn;
    prevRow = firstRow;
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:9,代碼來源:XlsTableReader.java

示例12: Cell

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public Cell(CellReference originalCell) {
    this(originalCell.getCol(), originalCell.getRow());
}
 
開發者ID:cuba-platform,項目名稱:yarg,代碼行數:4,代碼來源:Cell.java

示例13: extract

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public Map<String, Object[]> extract(Workbook workbook) {
	CellValueHelper helper = new CellValueHelper(workbook, true, this.locale);
	List<NamedCellInfo> list = ExcelUtils.createNamedCellList(workbook);
	Map<String, Object[]> map = new HashMap<String, Object[]>();
	for (NamedCellInfo info : list) {
		int currentLine = -1;
		int includeSize = 0;
		boolean hasValue = false;
		Sheet sheet = workbook.getSheet(info.
			getSheetName());
		List<Object> values = new ArrayList<Object>();
		for (CellReference cRef : info.getCellList()) {
			Cell cell = ExcelUtils.getOrCreateCell(sheet, cRef.getRow(), cRef.getCol());
			if (cRef.getRow() != currentLine) {
				currentLine = cRef.getRow();
				if (hasValue) {
					includeSize = values.size();
				}
				hasValue = false;
			}
			if (cell.getCellType() == Cell.CELL_TYPE_FORMULA && info.getCellList().size() > 1 && !includeFormulaValue) {
				continue;
			}
			FormattedValue fv = helper.getFormattedValue(cell);
			Object value = null;
			if (this.convertString) {
				value = fv.getValue();
			} else if (fv.getRawData() != null) {
				value = fv.getRawData();
			} else {
				switch (fv.getType()) {
					case NUMBER:
						value = cell.getNumericCellValue();
						break;
					case DATE:
						value = cell.getDateCellValue();
						break;
					case BOOLEAN:
						value = cell.getBooleanCellValue();
						break;
					default:
						value = fv.getValue();
						break;
				}
			}
			if (value != null && value.toString().length() > 0) {
				hasValue = true;
			}
			values.add(value);
		}
		if (hasValue) {
			includeSize = values.size();
		}
		map.put(info.getName(), values.subList(0, includeSize).toArray());
	}
	return map;
}
 
開發者ID:shunjikonishi,項目名稱:excel2canvas,代碼行數:58,代碼來源:NamedValueExtractor.java

示例14: createStepData

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
 * Setup the data necessary for Excel Writer step
 *
 * @param fileType
 * @throws KettleException
 */
private void createStepData( String fileType ) throws KettleException {
  stepData = new ExcelWriterStepData();
  stepData.inputRowMeta = step.getInputRowMeta().clone();
  stepData.outputRowMeta = step.getInputRowMeta().clone();

  // we don't run transformation so ExcelWriterStep.processRow() doesn't get executed
  // we populate the ExcelWriterStepData with bare minimum required values
  CellReference cellRef = new CellReference( stepMeta.getStartingCell() );
  stepData.startingRow = cellRef.getRow();
  stepData.startingCol = cellRef.getCol();
  stepData.posX = stepData.startingCol;
  stepData.posY = stepData.startingRow;

  int numOfFields = stepData.inputRowMeta.size();
  stepData.fieldnrs = new int[numOfFields];
  stepData.linkfieldnrs = new int[numOfFields];
  stepData.commentfieldnrs = new int[numOfFields];
  for ( int i = 0; i < numOfFields; i++ ) {
    stepData.fieldnrs[i] = i;
    stepData.linkfieldnrs[i] = -1;
    stepData.commentfieldnrs[i] = -1;
  }

  // we avoid reading/writing Excel files, so ExcelWriterStep.prepareNextOutputFile() doesn't get executed
  // create Excel workbook object
  stepData.wb = stepMeta.getExtension().equalsIgnoreCase( "xlsx" ) ? new XSSFWorkbook() : new HSSFWorkbook();
  stepData.sheet = stepData.wb.createSheet();
  stepData.file = null;
  stepData.clearStyleCache( numOfFields );

  // we avoid reading template file from disk
  // so set beforehand cells with custom style and formatting
  DataFormat format = stepData.wb.createDataFormat();
  Row xlsRow = stepData.sheet.createRow( 0 );

  // Cell F1 has custom style applied, used as template
  Cell cell = xlsRow.createCell( 5 );
  CellStyle cellStyle = stepData.wb.createCellStyle();
  cellStyle.setBorderRight( CellStyle.BORDER_THICK );
  cellStyle.setFillPattern( CellStyle.FINE_DOTS );
  cell.setCellStyle( cellStyle );

  // Cell G1 has same style, but also a custom data format
  cellStyle = stepData.wb.createCellStyle();
  cellStyle.cloneStyleFrom( cell.getCellStyle() );
  cell = xlsRow.createCell( 6 );
  cellStyle.setDataFormat( format.getFormat( "##0,000.0" ) );
  cell.setCellStyle( cellStyle );
}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:56,代碼來源:ExcelWriterStep_StyleFormatTest.java

示例15: CellAddress

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
 * CellAddressのインスタンスを作成する。
 * @param reference セルの參照形式。
 */
public CellAddress(final CellReference reference) {
    this(reference.getRow(), reference.getCol());
}
 
開發者ID:mygreen,項目名稱:xlsmapper,代碼行數:8,代碼來源:CellAddress.java


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