예제 #1
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));
     }
 }
예제 #2
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);
            }
        }