This project has moved. For the latest updates, please go here.

Background fill for empty cells within the table

Jun 4, 2014 at 1:22 PM
var backColor = XLColor.FromArgb(255, 255, 246);
wb.Worksheet(worksheetNum).ColumnsUsed().CellsUsed().Style.Fill.SetBackgroundColor(backColor);

This skips empty cells. Is there a way to make the background only for the cells within the table, but including empty cells?
Coordinator
Jun 4, 2014 at 3:42 PM
It's doing exactly what you're telling it to do: from the workbook give me the worksheet, then the columns used (have values), of those give me the cells that are being used (have values) then set the background color.

There are many ways to accomplish it but I'd probably do:

worksheet.RangeUsed().Style.Fill.BackgroundColor = XLColor.FromArgb(1);

You can also do:

cell.Style...
range.Style...
table.Style...
worksheet.Style...
row.Style...
column.Style...
Jun 4, 2014 at 3:54 PM
Ah! I didn't see the rage used function! Perfect, thanks!