Hello, the issue is the way you are using the cell.Style property.
DataGridViewCell on a row that do not have their own styling use the InheritedStyle property of the DataGridViewRow they are on.
Try this minor change:
foreach (DataGridViewRow row in DGV_Result.Rows)
{
int colindx = 0;
rowindx++;
foreach (DataGridViewCell cell in row.Cells)
{
colindx++;
ws.Cells[rowindx, colindx].Value = cell.EditedFormattedValue;
MessageBox.Show(row.DefaultCellStyle.BackColor.Name);
if (cell.InheritedStyle.BackColor == Color.Red)
{
ws.Cells[rowindx, colindx].Style.Fill.BackgroundColor.SetColor(Color.Red);
}
else if (cell.InheritedStyle.BackColor == Color.Yellow)
{
ws.Cells[rowindx, colindx].Style.Fill.BackgroundColor.SetColor(Color.Yellow);
}
else if (cell.InheritedStyle.BackColor == Color.Green)
{
ws.Cells[rowindx, colindx].Style.Fill.BackgroundColor.SetColor(Color.Green);
}
else
{
ws.Cells[rowindx, colindx].Style.Fill.BackgroundColor.SetColor(Color.White);
}
}
}
Hope that helps.