Example #1
0
 internal static string GetFormatCode(IExtendedFormat format)
 {
     if (format.NumberFormat != null)
     {
         if (BuiltInNumberFomrat.ContainsKey(format.NumberFormat.NumberFormatId) && (BuiltInNumberFomrat[format.NumberFormat.NumberFormatId] != format.NumberFormat.NumberFormatCode))
         {
             BuiltInNumberFomrat[format.NumberFormat.NumberFormatId] = format.NumberFormat.NumberFormatCode;
             return(format.NumberFormat.NumberFormatCode);
         }
         if (BuiltInNumberFomrat2.ContainsKey(format.NumberFormat.NumberFormatCode) && (BuiltInNumberFomrat2[format.NumberFormat.NumberFormatCode] != format.NumberFormat.NumberFormatId))
         {
             BuiltInNumberFomrat2[format.NumberFormat.NumberFormatCode] = format.NumberFormat.NumberFormatId;
             return(format.NumberFormat.NumberFormatCode);
         }
         if (!_customNumberFormat.ContainsKey(format.NumberFormat.NumberFormatCode))
         {
             _customNumberFormat.Add(format.NumberFormat.NumberFormatCode, format.NumberFormat.NumberFormatId);
         }
         return(format.NumberFormat.NumberFormatCode);
     }
     if (BuiltInNumberFomrat.ContainsKey(format.NumberFormatIndex))
     {
         return(BuiltInNumberFomrat[format.NumberFormatIndex]);
     }
     if (LanguageIndepedentNumberFormat.ContainsKey(format.NumberFormatIndex))
     {
         return(LanguageIndepedentNumberFormat[format.NumberFormatIndex]);
     }
     return("General");
 }
Example #2
0
        internal static XFRecrod GetXFBiffRecord(IExtendedFormat style, ushort fontID, IExcelWriter writer)
        {
            XFRecrod recrod = new XFRecrod {
                FontIndex = fontID,
                FillPatternBackgroundColor = (byte)writer.GetPaletteColor(style.PatternBackgroundColor),
                FillPatternColor           = (byte)writer.GetPaletteColor(style.PatternColor),
                FillPatternIndex           = (byte)style.FillPattern,
                HAlignment             = (byte)style.HorizontalAlign,
                VAlignment             = (byte)style.VerticalAlign,
                IndentLevel            = style.Indent,
                IsF123Prefix           = style.IsFirstSymbolApostrophe,
                IsHidden               = style.IsHidden,
                JustifyLastCharacter   = style.IsJustfyLastLine,
                IsLocked               = style.IsLocked,
                IsShrinkContent        = style.IsShrinkToFit,
                IsWordWrap             = style.IsWordWrap,
                Direction              = (byte)style.ReadingOrder,
                TextRotation           = (byte)style.Rotation,
                LeftBorderColorIndex   = (byte)writer.GetPaletteColor(style.Border.Left.Color),
                LeftBorderLine         = (byte)style.Border.Left.LineStyle,
                RightBorderColorIndex  = (byte)writer.GetPaletteColor(style.Border.Right.Color),
                RightBorderLine        = (byte)style.Border.Right.LineStyle,
                TopBorderColorIndex    = (byte)writer.GetPaletteColor(style.Border.Top.Color),
                TopBorderLine          = (byte)style.Border.Top.LineStyle,
                BottomBorderColorIndex = (byte)writer.GetPaletteColor(style.Border.Bottom.Color),
                BottomBorderLine       = (byte)style.Border.Bottom.LineStyle,
                ApplyAlignment         = style.ApplyAlignment,
                ApplyBorder            = style.ApplyBorder,
                ApplyFont              = style.ApplyFont,
                ApplyFill              = style.ApplyFill,
                ApplyNumberFormat      = style.ApplyNumberFormat,
                ApplyProtection        = style.ApplyProtection
            };

            if ((style is ExtendedFormat) && (style as ExtendedFormat).IsStyleFormat)
            {
                recrod.IsStyleXF     = true;
                recrod.ParentXFIndex = 0xfff;
            }
            else
            {
                recrod.IsStyleXF = false;
                if (style.ParentFormatID.HasValue)
                {
                    recrod.ParentXFIndex = (ushort)style.ParentFormatID.Value;
                }
                else
                {
                    recrod.ParentXFIndex = 15;
                }
            }
            if (style.NumberFormat != null)
            {
                recrod.FormatIndex = (ushort)style.NumberFormat.NumberFormatId;
                return(recrod);
            }
            recrod.FormatIndex = (ushort)style.NumberFormatIndex;
            return(recrod);
        }
Example #3
0
 public static string GetFormatCode(IExtendedFormat format)
 {
     if (format.NumberFormat != null)
     {
         return(format.NumberFormat.NumberFormatCode);
     }
     if (_builtInNumberFomrat.ContainsKey(format.NumberFormatIndex))
     {
         return(_builtInNumberFomrat[format.NumberFormatIndex]);
     }
     return(null);
 }
Example #4
0
 private void InitExcelColumnDefaultFormat()
 {
     this._columnFormat = ExtendedFormat.Default;
     if (this._owner != null)
     {
         if (this._owner.ExtendedFormats == null)
         {
             this._owner.ExtendedFormats = new Dictionary <int, IExtendedFormat>();
         }
         this.FormatId = this._owner.ExtendedFormats.Count;
         this._owner.ExtendedFormats.Add(this._owner.ExtendedFormats.Count, this._columnFormat);
     }
 }
Example #5
0
 private void Init()
 {
     this.Is1904Date                = false;
     this._precisionAsDisplay       = true;
     this._recalculateBeforeSave    = true;
     this.SaveExternalLinks         = false;
     this._calculationMode          = ExcelCalculationMode.Automatic;
     this._maximumIterations        = 100;
     this._isIterataCalculate       = false;
     this._maximumChange            = 0.001;
     this._externWorkbooks          = null;
     this._customOrFunctionNameList = null;
     this._builtInNameList          = null;
     this._namedCellRanges          = null;
     this._excelCellFormats         = null;
     this._defaultCellFormat        = null;
     this._excelCellFormats         = null;
     this._defaultCellFormat        = null;
     this._styleList                = null;
     this._tableStyles              = null;
     this._operator = null;
     this._sheets   = null;
     this.FirstDisplayedTabIndex    = 0;
     this.SelectedTabCount          = 0;
     this._activeSheetIndex         = 0;
     this.ActivePaneIndex           = 0;
     this.TabStripPolicy            = ExcelTabStripPolicy.Always;
     this._tabStripRatio            = 0.6;
     this.VerticalScrollBarPolicy   = ExcelScrollBarPolicy.AsNeeded;
     this.HorizontalScrollBarPolicy = ExcelScrollBarPolicy.AsNeeded;
     this._referenceStyle           = ExcelReferenceStyle.A1;
     this.Locked                = false;
     this.ExcelRect             = null;
     this.IsWindowHidden        = false;
     this.IsWindowDisplayAsIcon = false;
     if (this.ColorPalette != null)
     {
         this.ColorPalette = null;
     }
     if (this.DifferentialFormattings != null)
     {
         this.DifferentialFormattings = null;
     }
     this.Theme = null;
 }
Example #6
0
 public void SetExcelDefaultCellFormat(IExtendedFormat style)
 {
     this._workbook.DefaultCellFormat = style;
 }
Example #7
0
        public void SetExcelCellFormat(IExtendedFormat style)
        {
            Dictionary <int, IExtendedFormat> excelCellFormats = this._workbook.ExcelCellFormats;

            excelCellFormats.Add(excelCellFormats.Keys.Count, style);
        }