本文整理了Java中org.apache.poi.hssf.usermodel.HSSFSheet.getLastRowNum()
方法的一些代码示例,展示了HSSFSheet.getLastRowNum()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFSheet.getLastRowNum()
方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFSheet
类名称:HSSFSheet
方法名:getLastRowNum
[英]Gets the number last row on the sheet. Owing to idiosyncrasies in the excel file format, if the result of calling this method is zero, you can't tell if that means there are zero rows on the sheet, or one at position zero. For that case, additionally call #getPhysicalNumberOfRows() to tell if there is a row at position zero or not.
[中]获取工作表上最后一行的编号。由于excel文件格式的特殊性,如果调用此方法的结果为零,则无法判断这是否意味着工作表上有零行,或者在零位置有一行。对于这种情况,另外调用#getPhysicalNumberOfRows()来判断在位置0处是否有行。
代码示例来源:origin: org.apache.poi/poi
@Override
public void clearAllCachedResultValues() {
_lastDefinedRow = _hs.getLastRowNum();
}
}
代码示例来源:origin: org.apache.poi/poi
public HSSFEvaluationSheet(HSSFSheet hs) {
_hs = hs;
_lastDefinedRow = _hs.getLastRowNum();
}
代码示例来源:origin: org.apache.poi/poi
/**
* used internally to refresh the "first row" when the first row is removed.
*/
private int findFirstRow(int firstrow) {
int rownum = firstrow + 1;
HSSFRow r = getRow(rownum);
while (r == null && rownum <= getLastRowNum()) {
r = getRow(++rownum);
}
if (rownum > getLastRowNum())
return 0;
return rownum;
}
代码示例来源:origin: stackoverflow.com
/**
* Remove a row by its index
* @param sheet a Excel sheet
* @param rowIndex a 0 based index of removing row
*/
public static void removeRow(HSSFSheet sheet, int rowIndex) {
int lastRowNum=sheet.getLastRowNum();
if(rowIndex>=0&&rowIndex<lastRowNum){
sheet.shiftRows(rowIndex+1,lastRowNum, -1);
}
if(rowIndex==lastRowNum){
HSSFRow removingRow=sheet.getRow(rowIndex);
if(removingRow!=null){
sheet.removeRow(removingRow);
}
}
}
代码示例来源:origin: org.apache.poi/poi
/**
* add a row to the sheet
*
* @param addLow whether to add the row to the low level model - false if its already there
*/
private void addRow(HSSFRow row, boolean addLow) {
_rows.put(Integer.valueOf(row.getRowNum()), row);
if (addLow) {
_sheet.addRow(row.getRowRecord());
}
boolean firstRow = _rows.size() == 1;
if (row.getRowNum() > getLastRowNum() || firstRow) {
_lastrow = row.getRowNum();
}
if (row.getRowNum() < getFirstRowNum() || firstRow) {
_firstrow = row.getRowNum();
}
}
代码示例来源:origin: org.apache.poi/poi
if (hrow.getRowNum() == getLastRowNum()) {
_lastrow = findLastRow(_lastrow);
代码示例来源:origin: org.apache.poi/poi
int lastRow = sheet.getLastRowNum();
for(int j=firstRow;j<=lastRow;j++) {
HSSFRow row = sheet.getRow(j);
代码示例来源:origin: stackoverflow.com
worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1);
} else {
newRow = worksheet.createRow(destinationRowNum);
代码示例来源:origin: org.apache.poi/poi-examples
@Override
public int getSize() {
return sheet.getLastRowNum() + 1;
}
@Override
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
@Override
public void clearAllCachedResultValues() {
_lastDefinedRow = _hs.getLastRowNum();
}
}
代码示例来源:origin: bill1012/AdminEAP
public static HSSFSheet rowSpan(HSSFSheet sheet, int colindex, int contentBeginIndex) {
int rowNum = sheet.getLastRowNum();
HSSFRow row = sheet.getRow(1);
代码示例来源:origin: stackoverflow.com
public static int getMaxColumnNum(HSSFSheet ws) {
int rowNum = ws.getLastRowNum() + 1;
int max = 0;
int temp = 0;
for (int i = 0; i < rowNum; i++) {
temp = ws.getRow(i).getLastCellNum();
if (max < temp)
max = temp;
}
return max;
}
代码示例来源:origin: ckpoint/CheckPoint
/**
* Gets last row.
*
* @return the last row
*/
public Row getLastRow() {
return this.sheet.getRow(this.sheet.getLastRowNum());
}
代码示例来源:origin: org.seasar.dao-codegen/s2dao-codegen-core
protected Map<String, Table> readCodeData(HSSFSheet sheet) {
Map<String, Table> tableMap = new LinkedHashMap<String, Table>();
Table table = null;
for (int i = 1; i <= sheet.getLastRowNum(); ++i) {
HSSFRow row = sheet.getRow(i);
table = processRow(row, table, tableMap);
}
setupChildLinks(tableMap);
return tableMap;
}
代码示例来源:origin: QihooTest/Leo
public XlsTable(HSSFWorkbook workbook, String sheetName, HSSFSheet sheet) throws DataSetException {
int rowCount = sheet.getLastRowNum();
if (rowCount >= 0 && sheet.getRow(0) != null) {
_metaData = createMetaData(sheetName, sheet.getRow(0), workbook);
} else {
_metaData = new DefaultTableMetaData(sheetName, new Column[0]);
}
_sheet = sheet;
// Needed for later "BigDecimal"/"Number" conversion
symbols.setDecimalSeparator('.');
}
代码示例来源:origin: stackoverflow.com
public static void removeRow(HSSFSheet sheet, int rowIndex) {
int lastRowNum=sheet.getLastRowNum();
if(rowIndex>=0&&rowIndex<lastRowNum){
sheet.shiftRows(rowIndex+1,lastRowNum, -1);
}
if(rowIndex==lastRowNum){
HSSFRow removingRow=sheet.getRow(rowIndex);
if(removingRow!=null){
sheet.removeRow(removingRow);
}
}
}
代码示例来源:origin: org.databene/databene-formats
public void save(E bean) {
HSSFSheet sheet = getOrCreateSheet(bean, sheetName);
HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
for (int i = 0; i < beanProperties.size(); i++) {
PropFormat prop = beanProperties.get(i);
Object propValue = PropertyGraphAccessor.getPropertyGraph(prop.getName(), bean);
render(propValue, row, i);
}
}
代码示例来源:origin: stackoverflow.com
public void addCoverType(HSSFWorkbook workbook, List<Book> books) {
HSSFSheet sheet = workbook.getSheetAt(0);
HSSFCell cell = null;
//row 0 is the header (not automatically added by primefaces)
//add a fifth cell to each row
for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
sheet.getRow(i).createCell(4);
cell = sheet.getRow(i).getCell(4);
cell.setCellValue(book.get(i - 1).getCoverType());
}
log.debug("cover type added");
}
代码示例来源:origin: org.drools/drools-scorecards
public String peekValueAt(int row, int col) {
if (currentWorksheet != null){
if ( row >= 0 && row < currentWorksheet.getLastRowNum() ) {
HSSFRow hssfRow = currentWorksheet.getRow(row);
if (hssfRow != null && col >= 0 && col < hssfRow.getLastCellNum()){
return hssfRow.getCell(col).getStringCellValue();
}
}
}
return null;
}
代码示例来源:origin: cuba-platform/yarg
protected void cleanupCells(HSSFSheet resultSheet) {
for (int i = resultSheet.getFirstRowNum(); i <= resultSheet.getLastRowNum(); i++) {
HSSFRow row = resultSheet.getRow(i);
if (row != null) {
for (int j = 0; j < row.getLastCellNum(); j++) {
HSSFCell cell = row.getCell(j);
if (cell != null) {
row.removeCell(cell);
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!