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


Java CellReference.getSheetName方法代碼示例

本文整理匯總了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;
}
 
開發者ID:ykaragol,項目名稱:poi-data-validation,代碼行數:24,代碼來源:DataValidator.java

示例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;

}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:30,代碼來源:ExcelWriterStep.java

示例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;

}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:30,代碼來源:ExcelWriterStep.java

示例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;
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:17,代碼來源:ReferenceUtil.java

示例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();
	}
}
 
開發者ID:ykaragol,項目名稱:poi-data-validation,代碼行數:14,代碼來源:DataValidator.java

示例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;
}
 
開發者ID:uq-eresearch,項目名稱:aorra,代碼行數:32,代碼來源:SpreadsheetDataSource.java

示例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;
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:9,代碼來源:ExcelUtil.java

示例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;
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:10,代碼來源:XlsxTableReader.java

示例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;
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:9,代碼來源:XlsTableReader.java


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