本文整理了Java中org.apache.poi.ss.usermodel.Row.getSheet
方法的一些代码示例,展示了Row.getSheet
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Row.getSheet
方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Row
类名称:Row
方法名:getSheet
[英]Returns the Sheet this row belongs to
[中]返回此行所属的工作表
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Remove a row from this sheet. All cells contained in the row are removed as well
*
* @param row representing a row to remove.
*/
@Override
public void removeRow(Row row)
{
if (row.getSheet() != this) {
throw new IllegalArgumentException("Specified row does not belong to this sheet");
}
for(Iterator<Map.Entry<Integer, SXSSFRow>> iter = _rows.entrySet().iterator(); iter.hasNext();) {
Map.Entry<Integer, SXSSFRow> entry = iter.next();
if(entry.getValue() == row) {
iter.remove();
return;
}
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Return the cell's style.
*
* @return the cell's style. Always not-null. Default cell style has zero index and can be obtained as
* <code>workbook.getCellStyleAt(0)</code>
* @see org.apache.poi.ss.usermodel.Workbook#getCellStyleAt(int)
*/
@Override
public CellStyle getCellStyle()
{
if(_style == null){
SXSSFWorkbook wb = (SXSSFWorkbook)getRow().getSheet().getWorkbook();
return wb.getCellStyleAt(0);
} else {
return _style;
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
if (row.getSheet() != this) {
throw new IllegalArgumentException("Specified row does not belong to this sheet");
代码示例来源:origin: org.apache.poi/poi
/**
* Looks for text in the cell that should be unicode, like α and provides the
* unicode version of it.
*
*@param cell The cell to check for unicode values
*@return translated to unicode
*/
public static Cell translateUnicodeValues(Cell cell) {
String s = cell.getRichStringCellValue().getString();
boolean foundUnicode = false;
String lowerCaseStr = s.toLowerCase(Locale.ROOT);
for (UnicodeMapping entry : unicodeMappings) {
String key = entry.entityName;
if (lowerCaseStr.contains(key)) {
s = s.replaceAll(key, entry.resolvedValue);
foundUnicode = true;
}
}
if (foundUnicode) {
cell.setCellValue(cell.getRow().getSheet().getWorkbook().getCreationHelper()
.createRichTextString(s));
}
return cell;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
} else if (srcStartRow.getSheet().getWorkbook() != curRow.getSheet().getWorkbook()) {
throw new IllegalArgumentException("All rows in srcRows must belong to the same sheet in the same workbook. " +
"Expected all rows from same workbook (" + srcStartRow.getSheet().getWorkbook() + "). " +
"Got srcRows[" + index + "] from different workbook (" + curRow.getSheet().getWorkbook() + ").");
} else if (srcStartRow.getSheet() != curRow.getSheet()) {
throw new IllegalArgumentException("All rows in srcRows must belong to the same sheet. " +
"Expected all rows from " + srcStartRow.getSheet().getSheetName() + ". " +
"Got srcRows[" + index + "] from " + curRow.getSheet().getSheetName());
for (CellRangeAddress srcRegion : srcStartRow.getSheet().getMergedRegions()) {
if (srcStartRowNum <= srcRegion.getFirstRow() && srcRegion.getLastRow() <= srcEndRowNum) {
代码示例来源:origin: org.apache.poi/poi
/**
* Creates a cell, gives it a value, and applies a style if provided
*
* @param row the row to create the cell in
* @param column the column index to create the cell in
* @param value The value of the cell
* @param style If the style is not null, then set
* @return A new Cell
*/
public static Cell createCell(Row row, int column, String value, CellStyle style) {
Cell cell = getCell(row, column);
cell.setCellValue(cell.getRow().getSheet().getWorkbook().getCreationHelper()
.createRichTextString(value));
if (style != null) {
cell.setCellStyle(style);
}
return cell;
}
代码示例来源:origin: org.apache.poi/poi
public void removeRow(Row row) {
HSSFRow hrow = (HSSFRow) row;
if (row.getSheet() != this) {
throw new IllegalArgumentException("Specified row does not belong to this sheet");
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Shift a formula using the supplied FormulaShifter
*
* @param row the row of the cell this formula belongs to. Used to get a reference to the parent workbook.
* @param formula the formula to shift
* @param formulaShifter the FormulaShifter object that operates on the parsed formula tokens
* @return the shifted formula if the formula was changed,
* <code>null</code> if the formula wasn't modified
*/
/*package*/
static String shiftFormula(Row row, String formula, FormulaShifter formulaShifter) {
Sheet sheet = row.getSheet();
Workbook wb = sheet.getWorkbook();
int sheetIndex = wb.getSheetIndex(sheet);
final int rowIndex = row.getRowNum();
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create((XSSFWorkbook) wb);
try {
Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.CELL, sheetIndex, rowIndex);
String shiftedFmla = null;
if (formulaShifter.adjustFormula(ptgs, sheetIndex)) {
shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);
}
return shiftedFmla;
} catch (FormulaParseException fpe) {
// Log, but don't change, rather than breaking
logger.log(POILogger.WARN, "Error shifting formula on row ", row.getRowNum(), fpe);
return formula;
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
for (CellRangeAddress srcRegion : srcRow.getSheet().getMergedRegions()) {
if (srcRowNum == srcRegion.getFirstRow() && srcRowNum == srcRegion.getLastRow()) {
CellRangeAddress destRegion = srcRegion.copy();
代码示例来源:origin: tobyweston/simple-excel
private static List<Matcher<Row>> createCellMatchers(Row row) {
List<Matcher<Row>> matchers = new ArrayList<Matcher<Row>>();
for (Cell expected : row)
matchers.add(hasSameCell(row.getSheet(), expected));
return matchers;
}
代码示例来源:origin: tobyweston/simple-excel
@Override
public void describeTo(Description description) {
description.appendText("row ").appendValue(asExcelRow(expected)).appendText(" to be present")
.appendText(" in sheet ").appendValue(expected.getSheet().getSheetName());
}
}
代码示例来源:origin: tobyweston/simple-excel
@Override
protected boolean matchesSafely(Row actual, Description mismatch) {
if (actual == null) {
mismatch.appendText("row ").appendValue(asExcelRow(expected)).appendText(" is missing")
.appendText(" in sheet ").appendValue(expected.getSheet().getSheetName());
return false;
}
return true;
}
代码示例来源:origin: tobyweston/simple-excel
@Override
public void describeTo(Description description) {
description.appendValue(numberOfCellsIn(expected)).appendText(" cell(s) on row ").appendValue(asExcelRow(expected))
.appendText(" sheet ").appendValue(expected.getSheet().getSheetName());
}
代码示例来源: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 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 Object readErrorCell(Cell cell) {
if (isStrict()) {
throw new ExcelReadException("Error cell value encountered: %s@[%s]", cell.getAddress(), cell.getRow().getSheet().getSheetName());
}
return null;
}
代码示例来源:origin: Vatavuk/excel-io
@Override
public Cell attachTo(final Row row) {
final Cell cell = this.origin.attachTo(row);
cell.setCellStyle(row.getSheet().getWorkbook().createCellStyle());
for (final Style style : this.styles) {
style.attachTo(cell);
}
return cell;
}
代码示例来源: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: 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);
}
}
内容来源于网络,如有侵权,请联系作者删除!