Ejemplo n.º 1
0
        /// <summary>
        /// Reads additional records if needed: a string record might follow a formula result
        /// </summary>
        private Cell ReadSingleCell(XlsBiffStream biffStream, XlsBiffBlankCell cell, int numberFormatIndex)
        {
            LogManager.Log(this).Debug("ReadSingleCell {0}", cell.Id);

            double doubleValue;
            int    intValue;
            object objectValue;

            var result = new Cell()
            {
                ColumnIndex       = cell.ColumnIndex,
                NumberFormatIndex = numberFormatIndex
            };

            switch (cell.Id)
            {
            case BIFFRECORDTYPE.BOOLERR:
                if (cell.ReadByte(7) == 0)
                {
                    result.Value = cell.ReadByte(6) != 0;
                }
                break;

            case BIFFRECORDTYPE.BOOLERR_OLD:
                if (cell.ReadByte(8) == 0)
                {
                    result.Value = cell.ReadByte(7) != 0;
                }
                break;

            case BIFFRECORDTYPE.INTEGER:
            case BIFFRECORDTYPE.INTEGER_OLD:
                intValue     = ((XlsBiffIntegerCell)cell).Value;
                result.Value = TryConvertOADateTime(intValue, numberFormatIndex);
                break;

            case BIFFRECORDTYPE.NUMBER:
            case BIFFRECORDTYPE.NUMBER_OLD:
                doubleValue  = ((XlsBiffNumberCell)cell).Value;
                result.Value = TryConvertOADateTime(doubleValue, numberFormatIndex);
                break;

            case BIFFRECORDTYPE.LABEL:
            case BIFFRECORDTYPE.LABEL_OLD:
            case BIFFRECORDTYPE.RSTRING:
                result.Value = ((XlsBiffLabelCell)cell).GetValue(Encoding);
                break;

            case BIFFRECORDTYPE.LABELSST:
                result.Value = Workbook.SST.GetString(((XlsBiffLabelSSTCell)cell).SSTIndex, Encoding);
                break;

            case BIFFRECORDTYPE.RK:
                doubleValue  = ((XlsBiffRKCell)cell).Value;
                result.Value = TryConvertOADateTime(doubleValue, numberFormatIndex);
                break;

            case BIFFRECORDTYPE.BLANK:
            case BIFFRECORDTYPE.BLANK_OLD:
            case BIFFRECORDTYPE.MULBLANK:
                // Skip blank cells
                break;

            case BIFFRECORDTYPE.FORMULA:
            case BIFFRECORDTYPE.FORMULA_V3:
            case BIFFRECORDTYPE.FORMULA_V4:
                objectValue  = TryGetFormulaValue(biffStream, (XlsBiffFormulaCell)cell, numberFormatIndex);
                result.Value = objectValue;
                break;
            }

            LogManager.Log(this).Debug("VALUE: {0}", result.Value);

            return(result);
        }