public BordersStyleCacheItem(ExcelCellBordersStyle format)
 {
     LeftBorder   = format.LeftBorder == null ? null : new BorderCacheItem(format.LeftBorder);
     RightBorder  = format.RightBorder == null ? null : new BorderCacheItem(format.RightBorder);
     TopBorder    = format.TopBorder == null ? null : new BorderCacheItem(format.TopBorder);
     BottomBorder = format.BottomBorder == null ? null : new BorderCacheItem(format.BottomBorder);
 }
示例#2
0
        public uint AddStyle(ExcelCellBordersStyle format)
        {
            if (format == null)
            {
                return(0);
            }
            var cacheItem = new BordersStyleCacheItem(format);

            if (cache.TryGetValue(cacheItem, out var result))
            {
                return(result);
            }
            if (stylesheet.Borders == null)
            {
                var borders = new Borders {
                    Count = new UInt32Value(0u)
                };
                if (stylesheet.Fills != null)
                {
                    stylesheet.InsertAfter(borders, stylesheet.Fills);
                }
                else if (stylesheet.Fonts != null)
                {
                    stylesheet.InsertAfter(borders, stylesheet.Fonts);
                }
                else if (stylesheet.NumberingFormats != null)
                {
                    stylesheet.InsertAfter(borders, stylesheet.NumberingFormats);
                }
                else
                {
                    stylesheet.InsertAt(borders, 0);
                }
            }
            result = stylesheet.Borders.Count;
            stylesheet.Borders.AppendChild(cacheItem.ToBorder());
            stylesheet.Borders.Count++;
            cache.Add(cacheItem, result);
            return(result);
        }