本文整理汇总了Java中org.apache.poi.hssf.record.NumberRecord类的典型用法代码示例。如果您正苦于以下问题:Java NumberRecord类的具体用法?Java NumberRecord怎么用?Java NumberRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NumberRecord类属于org.apache.poi.hssf.record包,在下文中一共展示了NumberRecord类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isRowBlockRecord
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
static boolean isRowBlockRecord(int sid) {
switch (sid) {
case RowRecord.sid:
case BlankRecord.sid:
case BoolErrRecord.sid:
case FormulaRecord.sid:
case LabelRecord.sid:
case LabelSSTRecord.sid:
case NumberRecord.sid:
case RKRecord.sid:
case ArrayRecord.sid:
case SharedFormulaRecord.sid:
case TableRecord.sid:
return true;
}
return false;
}
示例2: formatNumberDateCell
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
/**
* Formats the given numeric of date Cell's contents as a String, in as
* close as we can to the way that Excel would do so. Uses the various
* format records to manage this.
*
* TODO - move this to a central class in such a way that hssf.usermodel can
* make use of it too
*/
public String formatNumberDateCell(CellValueRecordInterface cell) {
double value;
if (cell instanceof NumberRecord) {
value = ((NumberRecord) cell).getValue();
} else if (cell instanceof FormulaRecord) {
value = ((FormulaRecord) cell).getValue();
} else {
throw new IllegalArgumentException("Unsupported CellValue Record passed in " + cell);
}
// Get the built in format, if there is one
int formatIndex = getFormatIndex(cell);
String formatString = getFormatString(cell);
if (formatString == null) {
return _defaultFormat.format(value);
}
// Format, using the nice new
// HSSFDataFormatter to do the work for us
return _formatter.formatRawCellContents(value, formatIndex, formatString);
}
示例3: getValorLido
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
/**
* Recuper �ltimo valor lido pelo cabe�ote de leitura do XLS
* @return
*/
protected String getValorLido() {
String valorLido="";
if(xlsRecordAtual.getSid()== LabelSSTRecord.sid){
LabelSSTRecord labelSSTRecord = (LabelSSTRecord) xlsRecordAtual;
valorLido = sstrec.getString(labelSSTRecord.getSSTIndex()).toString();
}else if(xlsRecordAtual.getSid() == NumberRecord.sid){
NumberRecord numberRecord = (NumberRecord) xlsRecordAtual;
valorLido = converteDedoubleParaString(numberRecord);
}else{
log.warn("Atencao. A colula, linha nao pode ser lida!");
}
return valorLido;
}
示例4: getValorLido
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
/**
* Recuper �ltimo valor lido pelo cabe�ote de leitura do XLS
* @return
*/
protected String getValorLido() {
String valorLido="";
if(xlsRecordAtual.getSid()== LabelSSTRecord.sid){
LabelSSTRecord labelSSTRecord = (LabelSSTRecord) xlsRecordAtual;
valorLido = sstrec.getString(labelSSTRecord.getSSTIndex()).toString();
}else if(xlsRecordAtual.getSid() == NumberRecord.sid){
NumberRecord numberRecord = (NumberRecord) xlsRecordAtual;
valorLido = ""+numberRecord.getValue();
}else{
log.warn("Atencao. A colula, linha nao pode ser lida!");
}
return valorLido;
}
示例5: converteDedoubleParaString
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
private String converteDedoubleParaString(NumberRecord numrec) {
String value;
Double doublee = numrec.getValue();
Long l = doublee.longValue();
value = l.toString();
return value;
}
示例6: getLinhaAtual
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
/**
* Recupera linha atual a partir do recor que acabou de ser lifo
* @return
* @throws ControlePosicaoXLSException
*/
protected int getLinhaAtual() throws ControlePosicaoXLSException{
if(this.xlsRecordAtual.getSid()== LabelSSTRecord.sid){
LabelSSTRecord labelSSTRecord = (LabelSSTRecord) this.xlsRecordAtual;
return labelSSTRecord.getRow();
}else if(this.xlsRecordAtual.getSid() == NumberRecord.sid){
NumberRecord numberRecord = (NumberRecord) this.xlsRecordAtual;
return numberRecord.getRow();
}
throw new ControlePosicaoXLSException("O record atual n�o cont�m informacoes sobre linha e coluna!");
}
示例7: getColunaAtual
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
/**
* Recupera coluna atual a partir do record que acabou de ser lido
* @return
* @throws ControlePosicaoXLSException caso o record atual n�o permita leitura de coluna e linha
*/
protected short getColunaAtual() throws ControlePosicaoXLSException {
if(xlsRecordAtual.getSid()== LabelSSTRecord.sid){
LabelSSTRecord labelSSTRecord = (LabelSSTRecord) xlsRecordAtual;
return labelSSTRecord.getColumn();
}else if(xlsRecordAtual.getSid() == NumberRecord.sid){
NumberRecord numberRecord = (NumberRecord) xlsRecordAtual;
return numberRecord.getColumn();
}
throw new ControlePosicaoXLSException("O record atual n�o cont�m informacoes sobre linha e coluna!");
}
示例8: isPermiteLerLinhaColuna
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
/**
* Verifica se o Record atual permite ler informa��es sobre linha e coluna
* @return
*/
protected boolean isPermiteLerLinhaColuna() {
// Apenas os tipos LabelSSTRecord e NumberRecord permitem ler linha e coluna
return
this.xlsRecordAtual.getSid()==LabelSSTRecord.sid ||
this.xlsRecordAtual.getSid() ==NumberRecord.sid;
}
示例9: recordFound
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
@Override
protected void recordFound(Record record) throws Exception {
if(tableEnded)
return;
switch(record.getSid()) {
case BoundSheetRecord.sid:
boundRecord((BoundSheetRecord) record);
break;
case BOFRecord.sid:
bofRecord((BOFRecord)record);
break;
case SSTRecord.sid:
sstRecord = (SSTRecord) record;
break;
case BoolErrRecord.sid:
cellRecord((CellRecord)record);
break;
case FormulaRecord.sid:
cellRecord((CellRecord)record);
break;
case LabelSSTRecord.sid:
cellRecord((CellRecord)record);
break;
case LabelRecord.sid:
LabelRecord lr = (LabelRecord) record;
cellRecord(lr.getRow(), lr.getColumn(), lr);
break;
case StringRecord.sid:
if(outputNextString) {
cellRecord(prevRow, prevColumn, record);
outputNextString = false;
}
break;
case NumberRecord.sid:
cellRecord((CellRecord)record);
break;
default:
break;
}
}
示例10: cellRecord
import org.apache.poi.hssf.record.NumberRecord; //导入依赖的package包/类
private void cellRecord(int row, short column, Record record) throws Exception {
try {
//Not on the good sheet, before first row/column
if(!onReferencedSheet || firstRow > row || firstColumn > column)
return;
//The cell is empty, do not read it
boolean isEmptyCell = isEmpty(record);
if(isEmptyCell) {
//If first cell is empty, whole table is empty
if(firstRow==row && firstColumn == column)
lastColumn = (short)(firstColumn - 1);
return;
}
//Calculate the last column, based on the first row
if(firstRow == row) {
//If we missed a cell, do not read other columns
if((column - lastColumn) < 2)
lastColumn = column;
}
//after the last column
if(column > lastColumn)
return;
if(column == firstColumn)
prevColumn = firstColumn;
//missed a row, do not read further
if((row - prevRow)> 1 || (column-prevColumn)>1)
return;
short sid = record.getSid();
switch(sid) {
case NumberRecord.sid:
factory.numberFound(row, column, ((NumberRecord)record).getValue());
break;
case LabelSSTRecord.sid:
if(sstRecord == null)
throw new IllegalArgumentException("SSTRecord is null");
int stringId = ((LabelSSTRecord)record).getSSTIndex();
String str = sstRecord.getString(stringId).getString();
factory.stringFound(row, column, str);
break;
case LabelRecord.sid:
factory.stringFound(row, column, ((LabelRecord)record).getValue());
break;
case StringRecord.sid:
factory.stringFound(row, column, ((StringRecord)record).getString());
break;
case FormulaRecord.sid:
FormulaRecord fr = (FormulaRecord) record;
if(fr.hasCachedResultString()) {
outputNextString = true;
} else {
factory.numberFound(row, column, fr.getValue());
}
break;
case BoolErrRecord.sid:
BoolErrRecord ber = (BoolErrRecord) record;
if(ber.isBoolean()) {
factory.booleanFound(row, column, ber.getBooleanValue());
} else {
factory.errorFound(row, column, getErrorMsg(ber.getErrorValue()));
}
break;
default:
break;
}
prevRow = row;
prevColumn = column;
} catch (Exception ex) {
CellReference ref = new CellReference(sheetName, row, column, false, false);
throw new ExcelReadException(ref, ex);
}
}