org.apache.poi.hssf.record.StringRecord Java Examples
The following examples show how to use
org.apache.poi.hssf.record.StringRecord.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StringRecordHandler.java From easyexcel with Apache License 2.0 | 5 votes |
@Override public void processRecord(XlsReadContext xlsReadContext, Record record) { // String for formula StringRecord srec = (StringRecord)record; XlsReadSheetHolder xlsReadSheetHolder = xlsReadContext.xlsReadSheetHolder(); CellData tempCellData = xlsReadSheetHolder.getTempCellData(); if (tempCellData == null) { LOGGER.warn("String type formula but no value found."); return; } tempCellData.setStringValue(srec.getString()); xlsReadSheetHolder.getCellMap().put(tempCellData.getColumnIndex(), tempCellData); xlsReadSheetHolder.setTempCellData(null); }
Example #2
Source File: FormulaRecordAggregate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * @param stringRec may be <code>null</code> if this formula does not have a cached text * value. * @param svm the {@link SharedValueManager} for the current sheet */ public FormulaRecordAggregate(FormulaRecord formulaRec, StringRecord stringRec, SharedValueManager svm) { if (svm == null) { throw new IllegalArgumentException("sfm must not be null"); } if (formulaRec.hasCachedResultString()) { if (stringRec == null) { throw new RecordFormatException("Formula record flag is set but String record was not found"); } _stringRecord = stringRec; } else { // Usually stringRec is null here (in agreement with what the formula rec says). // In the case where an extra StringRecord is erroneously present, Excel (2007) // ignores it (see bug 46213). _stringRecord = null; } _formulaRecord = formulaRec; _sharedValueManager = svm; if (formulaRec.isSharedFormula()) { CellReference firstCell = formulaRec.getFormula().getExpReference(); if (firstCell == null) { handleMissingSharedFormulaRecord(formulaRec); } else { _sharedFormulaRecord = svm.linkSharedFormulaRecord(firstCell, this); } } }
Example #3
Source File: EventBasedExcelExtractor.java From lams with GNU General Public License v2.0 | 4 votes |
public void processRecord(Record record) { String thisText = null; int thisRow = -1; switch(record.getSid()) { case BoundSheetRecord.sid: BoundSheetRecord sr = (BoundSheetRecord)record; sheetNames.add(sr.getSheetname()); break; case BOFRecord.sid: BOFRecord bof = (BOFRecord)record; if(bof.getType() == BOFRecord.TYPE_WORKSHEET) { sheetNum++; rowNum = -1; if(_includeSheetNames) { if(_text.length() > 0) _text.append("\n"); _text.append(sheetNames.get(sheetNum)); } } break; case SSTRecord.sid: sstRecord = (SSTRecord)record; break; case FormulaRecord.sid: FormulaRecord frec = (FormulaRecord) record; thisRow = frec.getRow(); if(_formulasNotResults) { thisText = HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, frec.getParsedExpression()); } else { if(frec.hasCachedResultString()) { // Formula result is a string // This is stored in the next record outputNextStringValue = true; nextRow = frec.getRow(); } else { thisText = _ft.formatNumberDateCell(frec); } } break; case StringRecord.sid: if(outputNextStringValue) { // String for formula StringRecord srec = (StringRecord)record; thisText = srec.getString(); thisRow = nextRow; outputNextStringValue = false; } break; case LabelRecord.sid: LabelRecord lrec = (LabelRecord) record; thisRow = lrec.getRow(); thisText = lrec.getValue(); break; case LabelSSTRecord.sid: LabelSSTRecord lsrec = (LabelSSTRecord) record; thisRow = lsrec.getRow(); if(sstRecord == null) { throw new IllegalStateException("No SST record found"); } thisText = sstRecord.getString(lsrec.getSSTIndex()).toString(); break; case NoteRecord.sid: NoteRecord nrec = (NoteRecord) record; thisRow = nrec.getRow(); // TODO: Find object to match nrec.getShapeId() break; case NumberRecord.sid: NumberRecord numrec = (NumberRecord) record; thisRow = numrec.getRow(); thisText = _ft.formatNumberDateCell(numrec); break; default: break; } if(thisText != null) { if(thisRow != rowNum) { rowNum = thisRow; if(_text.length() > 0) _text.append("\n"); } else { _text.append("\t"); } _text.append(thisText); } }
Example #4
Source File: FormulaRecordAggregate.java From lams with GNU General Public License v2.0 | 2 votes |
/** * debug only * TODO - encapsulate */ public StringRecord getStringRecord() { return _stringRecord; }