示例#1
0
        private List <Cell> ReadMultiCell(XlsBiffBlankCell cell)
        {
            LogManager.Log(this).Debug("ReadMultiCell {0}", cell.Id);

            var result = new List <Cell>();

            switch (cell.Id)
            {
            case BIFFRECORDTYPE.MULRK:

                XlsBiffMulRKCell rkCell          = (XlsBiffMulRKCell)cell;
                ushort           lastColumnIndex = rkCell.LastColumnIndex;
                for (ushort j = cell.ColumnIndex; j <= lastColumnIndex; j++)
                {
                    var resultCell = new Cell()
                    {
                        ColumnIndex = j,
                        Value       = TryConvertOADateTime(rkCell.GetValue(j), rkCell.GetXF(j))
                    };

                    result.Add(resultCell);

                    LogManager.Log(this).Debug("VALUE[{1}]: {0}", resultCell.Value, j);
                }

                break;
            }

            return(result);
        }
示例#2
0
        private IEnumerable <Cell> ReadMultiCell(XlsBiffBlankCell cell)
        {
            LogManager.Log(this).Debug("ReadMultiCell {0}", cell.Id);

            switch (cell.Id)
            {
            case BIFFRECORDTYPE.MULRK:

                XlsBiffMulRKCell rkCell          = (XlsBiffMulRKCell)cell;
                ushort           lastColumnIndex = rkCell.LastColumnIndex;
                for (ushort j = cell.ColumnIndex; j <= lastColumnIndex; j++)
                {
                    var xfIndex        = rkCell.GetXF(j);
                    var effectiveStyle = Workbook.GetEffectiveCellStyle(xfIndex, cell.Format);

                    var value = TryConvertOADateTime(rkCell.GetValue(j), effectiveStyle.NumberFormatIndex);
                    LogManager.Log(this).Debug("CELL[{0}] = {1}", j, value);
                    yield return(new Cell(j, value, effectiveStyle));
                }

                break;
            }
        }
示例#3
0
        /// <summary>
        /// Returns false if more records are needed to parse the value. The caller is expected to retry after parsing a record into additionalRecords.
        /// </summary>
        private bool PushCellValue(object[] cellValues, XlsBiffBlankCell cell, ushort xFormat, List <XlsBiffRecord> additionalRecords)
        {
            double doubleValue;
            int    intValue;

            LogManager.Log(this).Debug("PushCellValue {0}", cell.Id);
            switch (cell.Id)
            {
            case BIFFRECORDTYPE.BOOLERR:
                if (cell.ReadByte(7) == 0)
                {
                    cellValues[cell.ColumnIndex] = cell.ReadByte(6) != 0;
                }
                break;

            case BIFFRECORDTYPE.BOOLERR_OLD:
                if (cell.ReadByte(8) == 0)
                {
                    cellValues[cell.ColumnIndex] = cell.ReadByte(7) != 0;
                }
                break;

            case BIFFRECORDTYPE.INTEGER:
            case BIFFRECORDTYPE.INTEGER_OLD:
                intValue = ((XlsBiffIntegerCell)cell).Value;
                cellValues[cell.ColumnIndex] = TryConvertOADateTime(intValue, xFormat);
                break;

            case BIFFRECORDTYPE.NUMBER:
            case BIFFRECORDTYPE.NUMBER_OLD:
                doubleValue = ((XlsBiffNumberCell)cell).Value;
                cellValues[cell.ColumnIndex] = TryConvertOADateTime(doubleValue, xFormat);
                LogManager.Log(this).Debug("VALUE: {0}", doubleValue);
                break;

            case BIFFRECORDTYPE.LABEL:
            case BIFFRECORDTYPE.LABEL_OLD:
            case BIFFRECORDTYPE.RSTRING:
                cellValues[cell.ColumnIndex] = ((XlsBiffLabelCell)cell).GetValue(Encoding);
                LogManager.Log(this).Debug("VALUE: {0}", cellValues[cell.ColumnIndex]);
                break;

            case BIFFRECORDTYPE.LABELSST:
                string tmp = Workbook.SST.GetString(((XlsBiffLabelSSTCell)cell).SSTIndex, Encoding);
                LogManager.Log(this).Debug("VALUE: {0}", tmp);
                cellValues[cell.ColumnIndex] = tmp;
                break;

            case BIFFRECORDTYPE.RK:
                doubleValue = ((XlsBiffRKCell)cell).Value;
                cellValues[cell.ColumnIndex] = TryConvertOADateTime(doubleValue, xFormat);
                LogManager.Log(this).Debug("VALUE: {0}", doubleValue);
                break;

            case BIFFRECORDTYPE.MULRK:

                XlsBiffMulRKCell rkCell          = (XlsBiffMulRKCell)cell;
                ushort           lastColumnIndex = rkCell.LastColumnIndex;
                for (ushort j = cell.ColumnIndex; j <= lastColumnIndex; j++)
                {
                    doubleValue = rkCell.GetValue(j);
                    LogManager.Log(this).Debug("VALUE[{1}]: {0}", doubleValue, j);
                    cellValues[j] = TryConvertOADateTime(doubleValue, rkCell.GetXF(j));
                }

                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:
                if (!TryGetFormulaValue((XlsBiffFormulaCell)cell, xFormat, additionalRecords, out object objectValue))
                {
                    // want additional records
                    return(false);
                }

                cellValues[cell.ColumnIndex] = objectValue;
                LogManager.Log(this).Debug("VALUE: {0}", objectValue);
                break;
            }

            return(true);
        }