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


Java CellReference.convertColStringToIndex方法代碼示例

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


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

示例1: mapHeaderToCellNum

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
private int mapHeaderToCellNum(Sheet sheet, String header, boolean createHeaderIfNotExisting) {
	if(configuration.getHeaders().get()) {
		Row row = sheet.getRow(0);
		if(row!=null) {
			for(Cell cell:row) {
				String key = ExcelFunctions.getCellValueAsString(cell, workbookSet.getMainFormulaEvaluator());
				if(key!=null && key.equals(header)) {
					return cell.getColumnIndex();
				}
			}				
		} else {
			if(createHeaderIfNotExisting) {
				sheet.createRow(0);
			} else {
				throw new ValidationException("The sheet " + sheet.getSheetName() + " contains no headers");				
			}
		}
		if(createHeaderIfNotExisting) {
			return addHeader(sheet, header);
		} else {
			throw new ValidationException("The column " + header + " doesn't exist in sheet " + sheet.getSheetName());				
		}
	} else {
		return CellReference.convertColStringToIndex(header);
	}
}
 
開發者ID:denkbar,項目名稱:step,代碼行數:27,代碼來源:ExcelDataPoolImpl.java

示例2: convertColumnIndex

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
protected int convertColumnIndex(Column column, String columnNumber) {
	int index;
	try {
		char c = columnNumber.charAt(0);
		if ('0' <= c && c <= '9') {
			index = Integer.parseInt(columnNumber) - 1;
		} else {
			index = CellReference.convertColStringToIndex(columnNumber);
		}
	} catch (Exception e) {
		throw new RuntimeException(MessageFormat.format("illegal column_number=\"{0}\" at {1}", columnNumber,
				column), e);
	}
	if (index < 0) {
		throw new RuntimeException(MessageFormat.format("illegal column_number=\"{0}\" at {1}", columnNumber,
				column));
	}
	return index;
}
 
開發者ID:hishidama,項目名稱:embulk-parser-poi_excel,代碼行數:20,代碼來源:PoiExcelColumnIndex.java

示例3: handleCellStart

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
 * Helper method to handle start of the "cell" element. It reads required attributes and set the workspace
 * variables.
 */
private void handleCellStart() {
  final String typeValue = xmlStreamReader.getAttributeValue(/*namespaceURI=*/null, ExcelUtil.TYPE);
  lookupNextValueInSST = ExcelUtil.SST_STRING.equals(typeValue);

  determineOutputTypes(
      typeValue,
      xmlStreamReader.getAttributeValue(/*namespaceURI=*/null, ExcelUtil.STYLE));
  currentCellRef = xmlStreamReader.getAttributeValue(/*namespaceURI=*/null, ExcelUtil.CELL_REF);
  String columnName = ExcelUtil.getColumnName(currentCellRef);
  currentColumnIndex = CellReference.convertColStringToIndex(columnName);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:16,代碼來源:StAXBasedParser.java

示例4: parse

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
public static CellIndex parse(String cellIndex) {
  	cellIndex = normalizeCellIndex(cellIndex);
  	
  	Integer rowNum;
Integer column;
Matcher cellIndexMatcher = CELL_INDEX_PATTERN.matcher(cellIndex);
if(cellIndexMatcher.matches()) {
	rowNum = Integer.decode(cellIndexMatcher.group(2));
	rowNum--; // In Excel 1-basiert, in poi 0-basiert
	column = CellReference.convertColStringToIndex(cellIndexMatcher.group(1));
	return new CellIndex(column, rowNum);
} else {
	throw new RuntimeException("Invalid cell index: '" + cellIndex + "'. Valid format are 'A1' or 'A::1'");
}
  }
 
開發者ID:denkbar,項目名稱:step,代碼行數:16,代碼來源:CellIndexParser.java

示例5: getColumnNumberFromCellRef

import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
 * return the column number from a cell reference (AA242)
 *
 * @param lastCell
 * @return
 */
public static int getColumnNumberFromCellRef(String lastCell) {

    StringBuilder letters = new StringBuilder();
    // get all letters to remove row number
    StringCharacterIterator iter = new StringCharacterIterator(lastCell);
    for (char c = iter.first(); c != StringCharacterIterator.DONE; c = iter.next()) {
        if (!NumberUtils.isNumber(String.valueOf(c))) {
            letters.append(c);
        }
    }
    // use poi api to calculate column number from an excell column format
    return CellReference.convertColStringToIndex(letters.toString());

}
 
開發者ID:Talend,項目名稱:data-prep,代碼行數:21,代碼來源:XlsUtils.java


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