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();
        }
        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;
            }
        }
 private CellStyle CreateStyleFromXF(XF xf)
 {
     CellStyle style = new CellStyle();
     style.BackColor = SharedResource.ColorPalette[xf.PatternColorIndex];
     return style;
 }