示例#1
0
        public static bool GetHasWhiteTheme(this SpreadsheetDocument document,
                                            string sheetName,
                                            string addressName)
        {
            var theCell = document.GetCellObject(sheetName, addressName);

            if (theCell.StyleIndex == null)
            {
                return(false);
            }
            int cellStyleIndex = (int)theCell.StyleIndex.Value;

            WorkbookPart       wbPart     = document.WorkbookPart;
            WorkbookStylesPart styles     = wbPart.WorkbookStylesPart.Stylesheet.WorkbookStylesPart;
            CellFormat         cellFormat = (CellFormat)styles.Stylesheet.CellFormats.ChildElements[cellStyleIndex];

            var font = (Font)styles.Stylesheet.Fonts.ChildElements[(int)cellFormat.FontId.Value];

            if (font == null)
            {
                return(false);
            }
            var color = font.Elements <Color>().FirstOrDefault();

            if (color == null)
            {
                return(false);
            }
            if (color.Theme == null)
            {
                return(false);
            }
            return(color.Theme.Value == 0); //0 white
        }
示例#2
0
        public static bool GetHasGoodFgColor(this SpreadsheetDocument document,
                                             string sheetName,
                                             string addressName)
        {
            var theCell = document.GetCellObject(sheetName, addressName);

            if (theCell.StyleIndex == null)
            {
                return(false);
            }
            int cellStyleIndex = (int)theCell.StyleIndex.Value;

            WorkbookPart       wbPart     = document.WorkbookPart;
            WorkbookStylesPart styles     = wbPart.WorkbookStylesPart.Stylesheet.WorkbookStylesPart;
            CellFormat         cellFormat = (CellFormat)styles.Stylesheet.CellFormats.ChildElements[cellStyleIndex];

            if (cellFormat.FillId == null)
            {
                return(false);
            }

            var fill = (Fill)styles.Stylesheet.Fills.ChildElements[(int)cellFormat.FillId.Value];

            if (fill == null)
            {
                return(false);
            }

            var patternFill = fill.Elements <PatternFill>().FirstOrDefault();

            if (patternFill == null)
            {
                return(false);
            }
            var color = patternFill.Elements <ForegroundColor>().FirstOrDefault();

            if (color == null)
            {
                return(false);
            }
            if (color.Rgb == null)
            {
                return(false);
            }
            return(color.Rgb.Value == "FFC6EFCE");
        }