本文整理匯總了Java中org.apache.poi.ss.util.CellReference.getSheetName方法的典型用法代碼示例。如果您正苦於以下問題:Java CellReference.getSheetName方法的具體用法?Java CellReference.getSheetName怎麽用?Java CellReference.getSheetName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.ss.util.CellReference
的用法示例。
在下文中一共展示了CellReference.getSheetName方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getReferenceList
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
private List<Object> getReferenceList(XSSFSheet sheet, DataValidationConstraint validationConstraint) {
List<Object> references = new LinkedList<>();
AreaReference areaRef = new AreaReference(validationConstraint.getFormula1());
CellReference[] cellRefs = areaRef.getAllReferencedCells();
for (CellReference cellRef : cellRefs) {
XSSFSheet referenceListSheet;
if (cellRef.getSheetName() != null) {
referenceListSheet = sheet.getWorkbook().getSheet(cellRef.getSheetName());
} else {
referenceListSheet = sheet;
}
Row row = referenceListSheet.getRow(cellRef.getRow());
if (row != null) {
Cell cell = row.getCell(cellRef.getCol());
if (cell != null) {
Object cellValue = CellValueParser.getCellValue(cell);
references.add(cellValue);
}
}
}
return references;
}
示例2: getCellFromReference
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
* @param reference
* @return the cell the refernce points to
*/
private Cell getCellFromReference(String reference) {
CellReference cellRef = new CellReference(reference);
String sheetName = cellRef.getSheetName();
Sheet sheet = data.sheet;
if (!Const.isEmpty(sheetName)) {
sheet = data.wb.getSheet(sheetName);
}
if (sheet == null) {
return null;
}
// reference is assumed to be absolute
Row xlsRow = sheet.getRow(cellRef.getRow());
if (xlsRow == null) {
return null;
}
Cell styleCell = xlsRow.getCell(cellRef.getCol());
return styleCell;
}
示例3: getCellFromReference
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
/**
* @param reference
* @return the cell the refernce points to
*/
private Cell getCellFromReference( String reference ) {
CellReference cellRef = new CellReference( reference );
String sheetName = cellRef.getSheetName();
Sheet sheet = data.sheet;
if ( !Utils.isEmpty( sheetName ) ) {
sheet = data.wb.getSheet( sheetName );
}
if ( sheet == null ) {
return null;
}
// reference is assumed to be absolute
Row xlsRow = sheet.getRow( cellRef.getRow() );
if ( xlsRow == null ) {
return null;
}
Cell styleCell = xlsRow.getCell( cellRef.getCol() );
return styleCell;
}
示例4: 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;
}
示例5: getSingleValue
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
private Double getSingleValue(XSSFSheet sheet, String formula) {
try {
return Double.parseDouble(formula);
} catch (NumberFormatException e) {
CellReference cellReference = new CellReference(formula);
if (cellReference.getSheetName() != null) {
sheet = sheet.getWorkbook().getSheet(cellReference.getSheetName());
}
XSSFRow row = sheet.getRow(cellReference.getRow());
XSSFCell cell = row.getCell(cellReference.getCol());
return cell.getNumericCellValue();
}
}
示例6: selectCell
import org.apache.poi.ss.util.CellReference; //導入方法依賴的package包/類
private Cell selectCell(String selector) throws MissingDataException {
// currently only CellReference selectors are supported like
// [sheet!]<row><column>
// e.g. Coral!A1 or just B20 which will select the cell from the first
// sheet.
CellReference cr = new CellReference(selector);
Sheet sheet;
String sheetName = cr.getSheetName();
if (sheetName != null) {
sheet = getSheet(sheetName);
if (sheet == null) {
throw new MissingDataException(String.format(
"Sheet '%s' does not exist in workbook", sheetName));
}
} else {
sheet = workbook.getSheetAt(defaultSheet);
if (sheet == null) {
throw new MissingDataException(
String.format("Sheet does not exist in workbook"));
}
}
Row row = sheet.getRow(cr.getRow());
if (row == null) {
return null;
}
Cell cell = row.getCell(cr.getCol());
if (cell == null) {
return null;
}
return cell;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}