org.apache.poi.ss.usermodel.Cell.getAddress()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(355)

本文整理了Java中org.apache.poi.ss.usermodel.Cell.getAddress()方法的一些代码示例,展示了Cell.getAddress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cell.getAddress()方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Cell
类名称:Cell
方法名:getAddress

Cell.getAddress介绍

[英]Gets the address of this cell
[中]获取此单元格的地址

代码示例

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-commons

private void setCellStringValue(Cell cell, String value) {
  try {
    cell.setCellValue(value);
  } catch (Exception e) {
    LOGGER.error(format("Unable to set string value for cell %s.", cell.getAddress()), e);
  }
}

代码示例来源:origin: stackoverflow.com

for (Cell cell : row) {
 if (! "".equals(String.valueOf(cell)))
 System.out.println(cell.getAddress() + ": " + String.valueOf(cell));
 CellStyle cellStyle = cell.getCellStyle();
 Color color = cellStyle.getFillForegroundColorColor();
 if (color != null) {
 if (color instanceof XSSFColor) {
  System.out.println(cell.getAddress() + ": " + ((XSSFColor)color).getARGBHex());
 } else if (color instanceof HSSFColor) {
  if (! (color instanceof HSSFColor.AUTOMATIC))
  System.out.println(cell.getAddress() + ": " + ((HSSFColor)color).getHexString());

代码示例来源:origin: io.choerodon/choerodon-starter-core

continue;
int column = cell.getAddress().getColumn();
String cellValue = cell.getStringCellValue();

代码示例来源:origin: choerodon/choerodon-starters

continue;
int column = cell.getAddress().getColumn();
String cellValue = cell.getStringCellValue();

代码示例来源:origin: io.choerodon/choerodon-starter-core

continue;
int column = cell.getAddress().getColumn();
String cellValue = getValue(cell);

代码示例来源:origin: choerodon/choerodon-starters

continue;
int column = cell.getAddress().getColumn();
String cellValue = getValue(cell);

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-commons

private String getCellStringValue(Cell cell, CellType cellType) {
  String data = EMPTY;
  try {
    switch (cellType) {
      case STRING:
        data = cell.getRichStringCellValue().toString();
        break;
      case NUMERIC:
        data = String.valueOf(cell.getNumericCellValue());
        break;
      case BOOLEAN:
        data = String.valueOf(cell.getBooleanCellValue());
        break;
      case FORMULA:
        data = getCellStringValue(cell, cell.getCachedFormulaResultTypeEnum());
        break;
      case BLANK:
      case ERROR:
      case _NONE:
        break;
    }
  } catch (Exception e) {
    LOGGER.error(format("Unable to get string value for cell %s.", cell.getAddress()), e);
  }
  return data;
}

代码示例来源:origin: stackoverflow.com

public CellAddress searchStringInXslx(String string) throws IOException{
     FileInputStream inputStream = new FileInputStream("Books.xlsx");
     Workbook workbook = new XSSFWorkbook(inputStream);
     Sheet firstSheet = workbook.getSheetAt(0);
     Iterator<Row> iterator = firstSheet.iterator();
     CellAddress columnNumber=null;
     while(iterator.hasNext()){
        Row nextRow = iterator.next();
        Iterator<Cell> cellIterator = nextRow.cellIterator();
        while (cellIterator.hasNext()) {
          Cell cell = cellIterator.next();
          if(cell.getCellType()==Cell.CELL_TYPE_STRING){ 
            String text = cell.getStringCellValue();
            if (string.equals(text)) {
              columnNumber=cell.getAddress();
              break;
            }
           }
          }
     }
     workbook.close();
     return columnNumber;
  }

代码示例来源:origin: stackoverflow.com

System.out.println(cell.getAddress() + " is green");
} else if(xssfCellColor.getARGBHex().equals(new XSSFColor(java.awt.Color.YELLOW).getARGBHex())) {
 System.out.println(cell.getAddress() + " is yellow");
 System.out.println(cell.getAddress() + " is green");
} else if(hssfCellColor.getHexString().equals("FFFF:FFFF:0")) {
 System.out.println(cell.getAddress() + " is yellow");

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-commons

private String focusCellAndDo(Action action, String cellAddress, String... value) {
  String data = null;
  try {
    CellReference cellRef = new CellReference(cellAddress);
    Cell cell = getCell(cellRef.getRow(), cellRef.getCol());
    CellType cellTyp = cell.getCellTypeEnum();
    CellAddress cellAd = cell.getAddress();
    if (action == Action.GET) {
      data = getCellStringValue(cell, cell.getCellTypeEnum());
      LOGGER.debug(format("Getting value of [%s] (%s) as [%s]", cellAd, cellTyp, data));
    } else if (action == Action.SET) {
      setCellStringValue(cell, value[0]);
      LOGGER.debug(format("Setting value of [%s] to [%s]", cellAd, value[0]));
      FileUtils.deleteFile(file.getPath());
      saveExcelFile();
    }
  } catch (Exception e) {
    LOGGER.error(e.getMessage(), e);
  }
  return data;
}

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-commons

private String iterateAndDo(Action action, String label, String... value) {
  String data = EMPTY;
  try {
    for (int dataRow = startRow; dataRow < worksheet.getLastRowNum() + 1; dataRow++) {
      Cell lblCell = getCell(dataRow, labelCol);
      Cell valCell = getCell(dataRow, valueCol);
      CellType lblCellTyp = lblCell.getCellTypeEnum();
      CellType valCellTyp = valCell.getCellTypeEnum();
      CellAddress valCellAd = valCell.getAddress();
      if (label.equals(getCellStringValue(lblCell, lblCellTyp))) {
        if (action == Action.GET) {
          data = getCellStringValue(valCell, valCellTyp);
          LOGGER.debug(format("Getting value of [%s] (%s) as [%s]", valCellAd, valCellTyp, data));
        } else if (action == Action.SET) {
          setCellStringValue(valCell, value[0]);
          LOGGER.debug(format("Setting value of [%s] to [%s]", valCellAd, value[0]));
          FileUtils.deleteFile(file.getPath());
          saveExcelFile();
        }
        break;
      }
    }
  } catch (Exception e) {
    LOGGER.error(e.getMessage(), e);
  }
  return data;
}

代码示例来源:origin: org.osgl/excel-reader

public Object readErrorCell(Cell cell) {
  if (isStrict()) {
    throw new ExcelReadException("Error cell value encountered: %s@[%s]", cell.getAddress(), cell.getRow().getSheet().getSheetName());
  }
  return null;
}

代码示例来源:origin: org.osgl/excel-reader

public Object readUnknownCellType(Cell cell) {
  if (isStrict()) {
    throw new ExcelReadException("Unknown cell type encountered: %s@[%s]", cell.getAddress(), cell.getRow().getSheet().getSheetName());
  }
  return null;
}

代码示例来源:origin: org.osgl/osgl-excel

public Object readErrorCell(Cell cell) {
  if (isStrict()) {
    throw new ExcelReadException("Error cell value encountered: %s@[%s]", cell.getAddress(), cell.getRow().getSheet().getSheetName());
  }
  return null;
}

代码示例来源:origin: org.osgl/osgl-excel

public Object readUnknownCellType(Cell cell) {
  if (isStrict()) {
    throw new ExcelReadException("Unknown cell type encountered: %s@[%s]", cell.getAddress(), cell.getRow().getSheet().getSheetName());
  }
  return null;
}

代码示例来源:origin: org.osgl/excel-reader

public void onReadCellException(Exception e, Cell cell) {
  String errorMessage = S.fmt("Error reading cell value: %s@[%s]", cell.getAddress(), cell.getSheet().getSheetName());
  if (isStrict()) {
    throw new ExcelReadException(e, errorMessage);
  }
  LOGGER.warn(e, errorMessage);
}

代码示例来源:origin: org.osgl/osgl-excel

public void onReadCellException(Exception e, Cell cell) {
  String errorMessage = S.fmt("Error reading cell value: %s@[%s]", cell.getAddress(), cell.getSheet().getSheetName());
  if (isStrict()) {
    throw new ExcelReadException(e, errorMessage);
  }
  LOGGER.warn(e, errorMessage);
}

代码示例来源:origin: org.osgl/excel-reader

public void errorSettingCellValueToPojo(Exception e, Cell cell, Object value, Class<?> schema) {
    String errorMessage = S.fmt("failed to set cell value[%s] to POJO[%s]: %s@[%s]", value, schema, cell.getAddress(), cell.getRow().getSheet().getSheetName());
    if (isStrict()) {
      throw new ExcelReadException(e, errorMessage);
    }
    LOGGER.warn(e, errorMessage);
  }
}

代码示例来源:origin: org.osgl/osgl-excel

public void errorSettingCellValueToPojo(Exception e, Cell cell, Object value, Class<?> schema) {
    String errorMessage = S.fmt("failed to set cell value[%s] to POJO[%s]: %s@[%s]", value, schema, cell.getAddress(), cell.getRow().getSheet().getSheetName());
    if (isStrict()) {
      throw new ExcelReadException(e, errorMessage);
    }
    LOGGER.warn(e, errorMessage);
  }
}

代码示例来源:origin: ZuInnoTe/hadoopoffice

comment = currentCellComment.getString().getString();
String address = currentCell.getAddress().toString();
String sheetName = currentCell.getSheet().getSheetName();
SpreadSheetCellDAO mySpreadSheetCellDAO = new SpreadSheetCellDAO(formattedValue,comment,formula,address,sheetName);

相关文章