コード例 #1
0
        public SharedResource(bool newbook)
        {
            FONT font = new FONT();
            font.Height = 200;
            font.OptionFlags = 0;
            font.ColorIndex = 32767;
            font.Weight = 400;
            font.Escapement = 0;
            font.Underline = 0;
            font.CharacterSet = 1;
            font.Name = "Arial";
            //Fonts.Add(font);

            for (ushort i = 0; i < 21; i++) // required by MS Excel 2003
            {
                XF xf = new XF();
                xf.Attributes = 252;
                xf.CellProtection = 65524;
                xf.PatternColorIndex = 64;
                xf.PatternBackgroundColorIndex = 130;
                xf.FontIndex = 0;
                xf.FormatIndex = i;
                ExtendedFormats.Add(xf);
            }

            MaxNumberFormatIndex = 163;
            GetXFIndex(CellFormat.General);

            SharedStringTable = new SST();
        }
コード例 #2
0
        public SharedResource(bool newbook)
        {
            for (ushort i = 0; i < 21; i++) // required by MS Excel 2003
            {
                var xf = new XF
                {
                    Attributes = 252,
                    CellProtection = 65524,
                    PatternColorIndex = 64,
                    PatternBackgroundColorIndex = 65,
                    FontIndex = 0,
                    FormatIndex = i
                };
                ExtendedFormats.Add(xf);
            }

            _maxNumberFormatIndex = 163;
            GetXFIndex(new CellFormat());

            SharedStringTable = new SST();
        }
コード例 #3
0
 private CellStyle CreateStyleFromXF(XF xf)
 {
     CellStyle style = new CellStyle();
     //style.BackColor = SharedResource.ColorPalette[xf.PatternColorIndex];
     return style;
 }
コード例 #4
0
        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;
        }
コード例 #5
0
 private CellFormat CreateCellFormatFromXF(XF xf)
 {
     var style = new CellFormat
     {
         FormatString = SharedResource.FormatStrings[xf.FormatIndex],
         //BackgroundColor = SharedResource.ColorPalette[xf.PatternColorIndex]
         // TODO: Read back all this stuff
     };
     return style;
 }
コード例 #6
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;
            }
        }
コード例 #7
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);
        }
コード例 #8
0
 private CellStyle CreateStyleFromXF(XF xf)
 {
     //throw new NotImplementedException();
     return new CellStyle();
 }