本文整理匯總了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);
}
}
示例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;
}
示例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);
}
示例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'");
}
}
示例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());
}