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); }
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); }
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); }
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)); } }