We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Row.ApplyStyle() is not applied to all cells in the row


Using Aspose.Cells v4.4.0.19, I colorize the entire row if some value is negative using the Row.ApplyStyle() method… Not all the cells are colored though, the “number” cells seem to have the style applied, but the “text” cell are left with their default style.

Below is some code to reproduce the problem. See attachment for an sample output.

Thanks for your support.


p.s. The document

is out of date where is states :
//Assigning the Style object to the Style property of the row
row.Style = style;

p.p.s I’ve tried with the latest official version and the problem is also there.

Aspose.Cells.Workbook xlsWorkbook;
xlsWorkbook = new Aspose.Cells.Workbook();

Aspose.Cells.Worksheet xlsSheet;

Aspose.Cells.Style xlsStyleRedForeground;
xlsStyleRedForeground = xlsWorkbook.Styles[xlsWorkbook.Styles.Add()];
xlsStyleRedForeground.Font.Color = System.Drawing.Color.Red;
xlsStyleRedForeground.Font.IsBold = true;

Aspose.Cells.StyleFlag styleFlag = new Aspose.Cells.StyleFlag();
styleFlag.All = true;

int idxRow = 0;
int idxCol = 0;

xlsSheet = xlsWorkbook.Worksheets[xlsWorkbook.Worksheets.ActiveSheetIndex];

// Output column headers
xlsSheet.Cells[idxRow, idxCol++].PutValue(“Col1”);
xlsSheet.Cells[idxRow, idxCol++].PutValue(“Col2”);
xlsSheet.Cells[idxRow, idxCol++].PutValue(“Col3”);
xlsSheet.Cells[idxRow, idxCol++].PutValue(“Col4”);
xlsSheet.Cells[idxRow, idxCol++].PutValue(“Col5”);

idxRow = idxRow + 3; idxCol = 0;

double rndValue;
Random randSeed = new Random();

for (int i=0; i<100; ++i) {
rndValue = Math.Round((randSeed.NextDouble() - 0.5) * 1000, 2);

xlsSheet.Cells[idxRow, idxCol++].PutValue(i+1);
xlsSheet.Cells[idxRow, idxCol++].PutValue(“Test string”);
xlsSheet.Cells[idxRow, idxCol++].PutValue(rndValue);
xlsSheet.Cells[idxRow, idxCol++].PutValue(rndValue);
xlsSheet.Cells[idxRow, idxCol++].PutValue(“Test string3”);

// Color line in red if value is negative
if (rndValue < 0) {
xlsSheet.Cells.Rows[idxRow].ApplyStyle(xlsStyleRedForeground, styleFlag);

idxRow = idxRow + 1; idxCol = 0;

if (xlsSheet != null) {


Thanks for the template file,

We will figure out the issue soon.

Thank you.


Please try this fix.

We have fixed this bug.

The issue seems to be fixed. Thank you for the quick support.