Exemple #1
0
            private Cell(X.Cell cell, X.SharedStringTable sst)
            {
                CellId   = cell.CellId;
                RawValue = cell.Value;

                switch (cell.CellType)
                {
                case X.CellDataType.None:
                    break;

                case X.CellDataType.Bool:
                    BoolValue = Convert.ToBoolean(RawValue);
                    DataType  = CellDataType.Bool;
                    break;

                case X.CellDataType.ISO8601Date:
                    DateTimeValue = DateTime.FromOADate(Convert.ToDouble(RawValue));
                    break;

                case X.CellDataType.Error:
                    ErrorText = RawValue;
                    DataType  = CellDataType.String;
                    break;

                case X.CellDataType.FormulaString:
                    StringValue = RawValue;
                    DataType    = CellDataType.Formula;
                    break;

                case X.CellDataType.InlineString:
                    StringValue = RawValue;
                    DataType    = CellDataType.String;
                    break;

                case X.CellDataType.Number:
                    DataType    = CellDataType.Number;
                    NumberValue = Convert.ToDouble(RawValue);
                    break;

                case X.CellDataType.SharedString:
                    StringValue = sst.Instances[int.Parse(RawValue)].Value;
                    DataType    = CellDataType.String;
                    break;

                default:
                    throw new Exception("Invalid value for c.@t (how did this happen?)");
                }

                var idParts = ParseCellId(CellId);

                Column = idParts.Item1;
                Row    = idParts.Item2;
            }
Exemple #2
0
 public Cell Create(X.Cell cell, X.SharedStringTable sst) => new Cell(cell, sst);