Examples of FormulaRecord


Examples of org.apache.poi.hssf.record.FormulaRecord

                break;
            default:
                throw new IllegalStateException("Unexpected cell type (" + _cellType + ")");
        }
        FormulaRecordAggregate fra = ((FormulaRecordAggregate)_record);
        FormulaRecord fr = fra.getFormulaRecord();
        switch (fr.getCachedResultType()) {
            case CELL_TYPE_BOOLEAN:
                return fr.getCachedBooleanValue() ? "TRUE" : "FALSE";
            case CELL_TYPE_STRING:
                return fra.getStringValue();
            case CELL_TYPE_NUMERIC:
                return NumberToTextConverter.toText(fr.getValue());
            case CELL_TYPE_ERROR:
                   return HSSFErrorConstants.getText(fr.getCachedErrorValue());
        }
        throw new IllegalStateException("Unexpected formula result type (" + _cellType + ")");
    }
View Full Code Here

Examples of org.apache.poi.hssf.record.FormulaRecord

            default:
                throw typeMismatch(CELL_TYPE_BOOLEAN, _cellType, false);
            case CELL_TYPE_FORMULA:
                break;
        }
        FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord();
        checkFormulaCachedValueType(CELL_TYPE_BOOLEAN, fr);
        return fr.getCachedBooleanValue();
    }
View Full Code Here

Examples of org.apache.poi.hssf.record.FormulaRecord

            default:
                throw typeMismatch(CELL_TYPE_ERROR, _cellType, false);
            case CELL_TYPE_FORMULA:
                break;
        }
        FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord();
        checkFormulaCachedValueType(CELL_TYPE_ERROR, fr);
        return (byte) fr.getCachedErrorValue();
    }
View Full Code Here

Examples of org.apache.poi.hssf.record.FormulaRecord

            case SSTRecord.sid: // holds all the strings for LabelSSTRecords
                sstRecord = (SSTRecord) record;
                break;

            case FormulaRecord.sid: // Cell value from a formula
                FormulaRecord formula = (FormulaRecord) record;
                addCell(record, new NumberCell(formula.getValue(), format));
                break;

            case LabelRecord.sid: // strings stored directly in the cell
                LabelRecord label = (LabelRecord) record;
                addTextCell(record, label.getValue());
View Full Code Here

Examples of org.apache.poi.hssf.record.FormulaRecord

      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;
View Full Code Here

Examples of org.apache.poi.hssf.record.FormulaRecord

      thisColumn = berec.getColumn();
      thisStr = "";
      break;

    case FormulaRecord.sid:
      FormulaRecord frec = (FormulaRecord) record;

      thisRow = frec.getRow();
      thisColumn = frec.getColumn();

      if(outputFormulaValues) {
        if(Double.isNaN( frec.getValue() )) {
          // Formula result is a string
          // This is stored in the next record
          outputNextStringRecord = true;
          nextRow = frec.getRow();
          nextColumn = frec.getColumn();
        } else {
          thisStr = formatListener.formatNumberDateCell(frec);
        }
      } else {
        thisStr = '"' +
          HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
      }
      break;
    case StringRecord.sid:
      if(outputNextStringRecord) {
        // String for formula
View Full Code Here

Examples of org.apache.poi.hssf.record.FormulaRecord

           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;
View Full Code Here

Examples of org.apache.poi.hssf.record.FormulaRecord

        assertEquals("Sheet1!A1", ptg.toFormulaString(book));


        // Now check we get the right formula back for
        //  a few sample ones
        FormulaRecord fr;

        // Sheet 1 A2 is on same sheet
        fr = fRecs[0];
        assertEquals(1, fr.getRow());
        assertEquals(0, fr.getColumn());
        assertEquals("Sheet1!A1", HSSFFormulaParser.toFormulaString(stubHSSF, fr.getParsedExpression()));

        // Sheet 1 A5 is to another sheet
        fr = fRecs[3];
        assertEquals(4, fr.getRow());
        assertEquals(0, fr.getColumn());
        assertEquals("'S2'!A1", HSSFFormulaParser.toFormulaString(stubHSSF, fr.getParsedExpression()));

        // Sheet 1 A7 is to another sheet, range
        fr = fRecs[5];
        assertEquals(6, fr.getRow());
        assertEquals(0, fr.getColumn());
        assertEquals("SUM(Sh3!A1:A4)", HSSFFormulaParser.toFormulaString(stubHSSF, fr.getParsedExpression()));


        // Now, load via Usermodel and re-check
        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("3dFormulas.xls");
        assertEquals("Sheet1!A1", wb.getSheetAt(0).getRow(1).getCell(0).getCellFormula());
View Full Code Here

Examples of org.apache.poi.hssf.record.FormulaRecord

      ((FormulaRecordAggregate)cvRec).notifyFormulaChanging();
    }
    _valuesAgg.removeCell(cvRec);
  }
  public FormulaRecordAggregate createFormula(int row, int col) {
    FormulaRecord fr = new FormulaRecord();
    fr.setRow(row);
    fr.setColumn((short) col);
    return new FormulaRecordAggregate(fr, null, _sharedValueManager);
  }
View Full Code Here

Examples of org.apache.poi.hssf.record.FormulaRecord

        }
        int sheetIndex = _book.getSheetIndex(_sheet);
        Ptg[] ptgs = HSSFFormulaParser.parse(formula, _book, FormulaType.CELL, sheetIndex);
        setCellType(CELL_TYPE_FORMULA, false, row, col, styleIndex);
        FormulaRecordAggregate agg = (FormulaRecordAggregate) _record;
        FormulaRecord frec = agg.getFormulaRecord();
        frec.setOptions((short) 2);
        frec.setValue(0);

        //only set to default if there is no extended format index already set
        if (agg.getXFIndex() == (short)0) {
            agg.setXFIndex((short) 0x0f);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.