Beispiel #1
0
        private static ExcelCell.Color GetFontColor(ExcelColor excelColor)
        {
            var color = new ExcelCell.Color()
            {
                rgb   = string.IsNullOrEmpty(excelColor.Rgb) ? null : excelColor.Rgb,
                theme = excelColor.Theme,
            };

            if (color.theme.HasValue)
            {
                color.tint = excelColor.Tint;
            }

            if (IsEmptyColor(color))
            {
                return(null);
            }

            // 通常色の場合は無視.
            if (color.theme == eThemeSchemeColor.Text1 && color.tint == 0)
            {
                return(null);
            }

            return(color);
        }
Beispiel #2
0
        private static bool IsEmptyColor(ExcelCell.Color color)
        {
            if (color == null)
            {
                return(true);
            }

            var hasValue = false;

            hasValue |= !string.IsNullOrEmpty(color.rgb);
            hasValue |= color.theme.HasValue;
            hasValue |= color.tint.HasValue;

            return(!hasValue);
        }
Beispiel #3
0
        private static ExcelCell.Color GetBackgroundColor(ExcelColor excelColor)
        {
            var color = new ExcelCell.Color()
            {
                rgb   = string.IsNullOrEmpty(excelColor.Rgb) ? null : excelColor.Rgb,
                theme = excelColor.Theme,
            };

            if (color.theme.HasValue)
            {
                color.tint = excelColor.Tint;
            }

            if (IsEmptyColor(color))
            {
                return(null);
            }

            return(color);
        }
Beispiel #4
0
        private static void SetColor(ExcelColor excelColor, ExcelCell.Color color)
        {
            if (IsEmptyColor(color))
            {
                return;
            }

            if (color.theme.HasValue)
            {
                excelColor.SetColor(color.theme.Value);

                if (color.tint.HasValue)
                {
                    excelColor.Tint = color.tint.Value;
                }
            }
            else
            {
                excelColor.SetColor(ColorTranslator.FromHtml("#" + color.rgb));
            }
        }