/// <summary> /// Will add a cell to the spreadsheet to export with the passed address with given context. /// </summary> /// <param name="address">Where to add the cell.</param> /// <param name="content">What to write in it.</param> /// <param name="col">What coloring to apply for that cell.</param> private void addCell(string address, string content, coloring col = coloring.none) { _sheet.Cells[address].Value = content; applyCellStyling(address, col); }
/// <summary> /// Applies the styling for a single cell based on the colorin enum. /// </summary> private void applyCellStyling(string address, coloring col) { _sheet.Cells[address].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; Color background = Color.White; Color foreground = Color.Black; ColorHolder chbg = Settings.Static.ColorSettings.NoneBG; ColorHolder chfg = Settings.Static.ColorSettings.NoneFG; if (col == coloring.neutral) { chbg = Settings.Static.ColorSettings.NeutralBG; chfg = Settings.Static.ColorSettings.NeutralFG; } else if (col == coloring.negative) { chbg = Settings.Static.ColorSettings.NegativeBG; chfg = Settings.Static.ColorSettings.NegativeFG; } else if (col == coloring.positive) { chbg = Settings.Static.ColorSettings.PositiveBG; chfg = Settings.Static.ColorSettings.PositiveFG; } background = Color.FromArgb(chbg.R, chbg.G, chbg.B); foreground = Color.FromArgb(chfg.R, chfg.G, chfg.B); _sheet.Cells[address].Style.Fill.BackgroundColor.SetColor(background); _sheet.Cells[address].Style.Font.Color.SetColor(foreground); }