public void Add(FORMAT record)
 {
     if (record != null)
     {
         if (this.lookupTable.ContainsKey(record.FormatIndex))
         {
             CellFormat cellFormat = this.lookupTable[record.FormatIndex];
             this.lookupTable[record.FormatIndex] = new CellFormat(cellFormat.FormatType, record.FormatString);
         }
         else
         {
             this.lookupTable.Add(record.FormatIndex, new CellFormat(CellFormatType.Custom, record.FormatString));
         }
     }
 }
示例#2
0
 public void Add(FORMAT record)
 {
     if (record == null) return;
     // Built-in cell formula may change due to regional settings            
     // therefore, we allow caller to replace built-in cell format      
     if (this.lookupTable.ContainsKey(record.FormatIndex))
     {
         CellFormat oldCellFormat = this.lookupTable[record.FormatIndex];
         this.lookupTable[record.FormatIndex] = new CellFormat(oldCellFormat.FormatType, record.FormatString);
     }
     else
     {
         this.lookupTable.Add(record.FormatIndex, new CellFormat(CellFormatType.Custom, record.FormatString));
     }
 }
示例#3
0
 public void Add(FORMAT record)
 {
     if (record == null)
     {
         return;
     }
     // Built-in cell formula may change due to regional settings
     // therefore, we allow caller to replace built-in cell format
     if (this.lookupTable.ContainsKey(record.FormatIndex))
     {
         CellFormat oldCellFormat = this.lookupTable[record.FormatIndex];
         this.lookupTable[record.FormatIndex] = new CellFormat(oldCellFormat.FormatType, record.FormatString);
     }
     else
     {
         this.lookupTable.Add(record.FormatIndex, new CellFormat(CellFormatType.Custom, record.FormatString));
     }
 }
示例#4
0
        internal int GetXFIndex(CellFormat cellFormat)
        {
            string formatString = cellFormat.FormatString;

            checked
            {
                int result;
                if (this.NumberFormatXFIndice.ContainsKey(formatString))
                {
                    result = this.NumberFormatXFIndice[formatString];
                }
                else
                {
                    ushort num = this.CellFormats.GetFormatIndex(formatString);
                    if (num == 65535)
                    {
                        ushort maxNumberFormatIndex;
                        this.MaxNumberFormatIndex = (ushort)((maxNumberFormatIndex = this.MaxNumberFormatIndex) + 1);
                        num = maxNumberFormatIndex;
                    }
                    FORMAT fORMAT = new FORMAT();
                    fORMAT.FormatIndex  = num;
                    fORMAT.FormatString = formatString;
                    this.FormatRecords.Add(fORMAT);
                    XF xF = new XF();
                    xF.Attributes                  = 252;
                    xF.CellProtection              = 0;
                    xF.PatternColorIndex           = 64;
                    xF.PatternBackgroundColorIndex = 130;
                    xF.FontIndex   = 0;
                    xF.FormatIndex = num;
                    this.ExtendedFormats.Add(xF);
                    int num2 = this.ExtendedFormats.Count - 1;
                    this.NumberFormatXFIndice.Add(formatString, num2);
                    result = num2;
                }
                return(result);
            }
        }
示例#5
0
        internal int GetXFIndex(CellFormat cellFormat)
        {
            string formatString = cellFormat.FormatString;

            if (NumberFormatXFIndice.ContainsKey(formatString))
            {
                return(NumberFormatXFIndice[formatString]);
            }
            else
            {
                UInt16 formatIndex = CellFormats.GetFormatIndex(formatString);
                if (formatIndex == UInt16.MaxValue)
                {
                    formatIndex = MaxNumberFormatIndex++;
                }

                FORMAT format = new FORMAT();
                format.FormatIndex  = formatIndex;
                format.FormatString = formatString;
                FormatRecords.Add(format);

                XF xf = new XF();
                xf.Attributes                  = 252;
                xf.CellProtection              = 0;
                xf.PatternColorIndex           = 64;
                xf.PatternBackgroundColorIndex = 130;
                xf.FontIndex   = 0;
                xf.FormatIndex = formatIndex;
                ExtendedFormats.Add(xf);

                int numberFormatXFIndex = ExtendedFormats.Count - 1;
                NumberFormatXFIndice.Add(formatString, numberFormatXFIndex);

                return(numberFormatXFIndex);
            }
        }
        internal int GetXFIndex(CellFormat cellFormat)
        {
            string formatKey = cellFormat.ToString();
            if (_cellFormatIndexLookup.ContainsKey(formatKey))
            {
                return _cellFormatIndexLookup[formatKey];
            }

            UInt16 formatIndex = FormatStrings.GetFormatIndex(cellFormat.FormatString.Value);
            if (formatIndex == UInt16.MaxValue)
            {
                formatIndex = _maxNumberFormatIndex++;
            }
            var format = new FORMAT
            {
                FormatIndex = formatIndex,
                FormatString = cellFormat.FormatString.Value
            };
            StringFormatRecords.Add(format);

            ushort fontIndex = Fonts.GetIndex(cellFormat.Font);

            var xf = new XF
            {
                FontIndex = fontIndex,
                FormatIndex = formatIndex,
                Attributes = 252,
                FillPattern = (byte)cellFormat.Pattern.Style,
                PatternColorIndex = cellFormat.Pattern.ForegroundColor.Index,
                PatternBackgroundColorIndex = cellFormat.Pattern.BackgroundColor.Index,
                TopLineStyle = (byte)cellFormat.Border.TopStyle,
                BottomLineStyle = (byte)cellFormat.Border.BottomStyle,
                LeftLineStyle = (byte)cellFormat.Border.LeftStyle,
                RightLineStyle = (byte)cellFormat.Border.RightStyle,
                TopLineColorIndex = cellFormat.Border.TopColor.Index,
                BottomLineColorIndex = cellFormat.Border.BottomColor.Index,
                LeftLineColorIndex = cellFormat.Border.LeftColor.Index,
                RightLineColorIndex = cellFormat.Border.RightColor.Index,
                DiagonalUp = cellFormat.Border.DiagonalUp,
                DiagonalDown = cellFormat.Border.DiagonalDown,
                DiagonalLineStyle = (byte)cellFormat.Border.DiagonalStyle,
                DiagonalLineColorIndex = cellFormat.Border.DiagonalColor.Index,
                CellLocked = cellFormat.LockCell,
                FormulaHidden = cellFormat.HideFormula,
                HorizontalAlign = (byte)cellFormat.TextControl.HorizontalAlignment,
                VerticalAlign = (byte)cellFormat.TextControl.VerticalAlignment,
                TextWrap = cellFormat.TextControl.WrapText,
                JustifyDistributed = cellFormat.TextControl.JustifyDistributed,
                ShrinkContents = cellFormat.TextControl.ShrinkToFit,
                IndentLevel = cellFormat.TextControl.IndentLevel,
                TextDirection = (byte)cellFormat.TextControl.TextDirection
            };
            switch (cellFormat.TextControl.RotationStyle)
            {
                case RotationStyle.CounterClockwise:
                    xf.Rotation = cellFormat.TextControl.TextRotation;
                    break;
                case RotationStyle.Clockwise:
                    xf.Rotation = (byte)(cellFormat.TextControl.TextRotation + 90);
                    break;
                case RotationStyle.Stacked:
                    xf.Rotation = 255;
                    break;
                default:
                    xf.Rotation = 0;
                    break;
            }

            ExtendedFormats.Add(xf);

            _cellFormatIndexLookup.Add(formatKey, ExtendedFormats.Count - 1);

            return ExtendedFormats.Count - 1;
        }
        internal int GetXFIndex(CellFormat cellFormat)
        {
            string formatString = cellFormat.FormatString;
            if (NumberFormatXFIndice.ContainsKey(formatString))
            {
                return NumberFormatXFIndice[formatString];
            }
            else
            {
                UInt16 formatIndex = CellFormats.GetFormatIndex(formatString);
                if (formatIndex == UInt16.MaxValue)
                {
                    formatIndex = MaxNumberFormatIndex++;
                }

                FORMAT format = new FORMAT();
                format.FormatIndex = formatIndex;
                format.FormatString = formatString;
                FormatRecords.Add(format);

                XF xf = new XF();
                xf.Attributes = 252;
                xf.CellProtection = 0;
                xf.PatternColorIndex = 64;
                xf.PatternBackgroundColorIndex = 130;
                xf.FontIndex = 0;
                xf.FormatIndex = formatIndex;
                ExtendedFormats.Add(xf);

                int numberFormatXFIndex = ExtendedFormats.Count - 1;
                NumberFormatXFIndice.Add(formatString, numberFormatXFIndex);

                return numberFormatXFIndex;
            }
        }
示例#8
0
        public static Record Read(Stream stream)
        {
            Record record = Record.ReadBase(stream);
            ushort type   = record.Type;
            Record result;

            if (type <= 146)
            {
                if (type <= 49)
                {
                    if (type <= 13)
                    {
                        if (type == 6)
                        {
                            result = new FORMULA(record);
                            return(result);
                        }
                        switch (type)
                        {
                        case 10:
                            result = new EOF(record);
                            return(result);

                        case 12:
                            result = new CALCCOUNT(record);
                            return(result);

                        case 13:
                            result = new CALCMODE(record);
                            return(result);
                        }
                    }
                    else
                    {
                        if (type == 34)
                        {
                            result = new DATEMODE(record);
                            return(result);
                        }
                        if (type == 41)
                        {
                            result = new BOTTOMMARGIN(record);
                            return(result);
                        }
                        if (type == 49)
                        {
                            result = new FONT(record);
                            return(result);
                        }
                    }
                }
                else
                {
                    if (type <= 93)
                    {
                        switch (type)
                        {
                        case 60:
                            result = new CONTINUE(record);
                            return(result);

                        case 61:
                            result = new WINDOW1(record);
                            return(result);

                        case 62:
                        case 63:
                        case 65:
                            break;

                        case 64:
                            result = new BACKUP(record);
                            return(result);

                        case 66:
                            result = new CODEPAGE(record);
                            return(result);

                        default:
                            if (type == 85)
                            {
                                result = new DEFCOLWIDTH(record);
                                return(result);
                            }
                            if (type == 93)
                            {
                                result = new OBJ(record);
                                return(result);
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (type == 125)
                        {
                            result = new COLINFO(record);
                            return(result);
                        }
                        if (type == 133)
                        {
                            result = new BOUNDSHEET(record);
                            return(result);
                        }
                        if (type == 146)
                        {
                            result = new PALETTE(record);
                            return(result);
                        }
                    }
                }
            }
            else
            {
                if (type <= 237)
                {
                    if (type <= 190)
                    {
                        if (type == 153)
                        {
                            result = new STANDARDWIDTH(record);
                            return(result);
                        }
                        switch (type)
                        {
                        case 189:
                            result = new MULRK(record);
                            return(result);

                        case 190:
                            result = new MULBLANK(record);
                            return(result);
                        }
                    }
                    else
                    {
                        switch (type)
                        {
                        case 214:
                            result = new RSTRING(record);
                            return(result);

                        case 215:
                            result = new DBCELL(record);
                            return(result);

                        case 216:
                        case 217:
                            break;

                        case 218:
                            result = new BOOKBOOL(record);
                            return(result);

                        default:
                            if (type == 224)
                            {
                                result = new XF(record);
                                return(result);
                            }
                            switch (type)
                            {
                            case 233:
                                result = new BITMAP(record);
                                return(result);

                            case 235:
                                result = new MSODRAWINGGROUP(record);
                                return(result);

                            case 236:
                                result = new MSODRAWING(record);
                                return(result);

                            case 237:
                                result = new MSODRAWINGSELECTION(record);
                                return(result);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    if (type <= 545)
                    {
                        switch (type)
                        {
                        case 252:
                            result = new SST(record);
                            return(result);

                        case 253:
                            result = new LABELSST(record);
                            return(result);

                        case 254:
                            break;

                        case 255:
                            result = new EXTSST(record);
                            return(result);

                        default:
                            switch (type)
                            {
                            case 512:
                                result = new DIMENSIONS(record);
                                return(result);

                            case 513:
                                result = new BLANK(record);
                                return(result);

                            case 514:
                            case 516:
                            case 518:
                                break;

                            case 515:
                                result = new NUMBER(record);
                                return(result);

                            case 517:
                                result = new BOOLERR(record);
                                return(result);

                            case 519:
                                result = new STRING(record);
                                return(result);

                            case 520:
                                result = new ROW(record);
                                return(result);

                            default:
                                if (type == 545)
                                {
                                    result = new ARRAY(record);
                                    return(result);
                                }
                                break;
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (type == 638)
                        {
                            result = new RK(record);
                            return(result);
                        }
                        if (type == 1054)
                        {
                            result = new FORMAT(record);
                            return(result);
                        }
                        if (type == 2057)
                        {
                            result = new BOF(record);
                            return(result);
                        }
                    }
                }
            }
            result = record;
            return(result);
        }