/// <summary> /// Format cells in the range into a table /// </summary> /// <param name="range">The table's cells</param> /// <param name="color">Color palette of the table</param> /// <param name="showColumnHeader">Defines if the table has column header</param> /// <param name="showRowHeader">Defines if the table has row header</param> public static void FormatAsTable(this ExcelRange range, ExcelColor color = ExcelColor.Primary, bool showColumnHeader = true, bool showRowHeader = true) { var ws = range.Worksheet; var palette = PaletteStorage.GetPalette(color); range.BorderEverywhere(); //First fill every cell as Light color from palette range.Fill(palette.LightColor); //Row header's color is main if (showRowHeader) { //row header starts from first row first column, and ends at first row last column var headerRange = ws.Cells[range.Start.Row, range.Start.Column, range.End.Row, range.Start.Column]; headerRange.Fill(palette.MainColor); } //Column header's color is main if (showColumnHeader) { //Column header starts from first row first column, and ends at first row last column var headerRange = ws.Cells[range.Start.Row, range.Start.Column, range.Start.Row, range.End.Column]; headerRange.Fill(palette.MainColor); } }