本文整理汇总了Java中org.apache.poi.hssf.record.FormulaRecord类的典型用法代码示例。如果您正苦于以下问题:Java FormulaRecord类的具体用法?Java FormulaRecord怎么用?Java FormulaRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FormulaRecord类属于org.apache.poi.hssf.record包,在下文中一共展示了FormulaRecord类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.poi.hssf.record.FormulaRecord; //导入依赖的package包/类
public void process(Record r) {
switch (r.getSid()) {
case MergeCellsRecord.sid:
mergeCellRecords.add((MergeCellsRecord) r);
break;
case SharedFormulaRecord.sid:
shFrmRecords.add((SharedFormulaRecord) r);
if (!(prevRec instanceof FormulaRecord)) {
throw new RuntimeException("Shared formula record should follow a FormulaRecord");
}
FormulaRecord fr = (FormulaRecord) prevRec;
firstCellRefs.add(new CellReference(fr.getRow(), fr.getColumn()));
break;
case ArrayRecord.sid:
arrayRecords.add((ArrayRecord) r);
break;
case TableRecord.sid:
tableRecords.add((TableRecord) r);
break;
default:
plainRecords.add(r);
break;
}
prevRec = r;
}
示例2: isRowBlockRecord
import org.apache.poi.hssf.record.FormulaRecord; //导入依赖的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;
}
示例3: formatNumberDateCell
import org.apache.poi.hssf.record.FormulaRecord; //导入依赖的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);
}
示例4: recordFound
import org.apache.poi.hssf.record.FormulaRecord; //导入依赖的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;
}
}
示例5: cellRecord
import org.apache.poi.hssf.record.FormulaRecord; //导入依赖的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);
}
}