If I insert a row in a worksheet at index 0, and then apply a style to that row (for example making the font bold), and then insert a new row using either
Cells.InsertRows() at row index 1 (underneath the first row), the second row that is created is also bold, though I didn’t apply any styling to that row.
In the generated file, ‘Second Row we Created’ is bold even though I didn’t apply a bold styling to that row.
See the following code snippet:
Workbook workbook = new Workbook(); workbook.Worksheets.Cells.InsertRows(0, 1);//insert 1 row at row index 0 //set the property of that row we just inserted, using the index //create a new style to apply to the first row we just created var style = workbook.CreateStyle(); var flag = new StyleFlag(); style.Font.IsBold = true; flag.FontBold = true; workbook.Worksheets.Cells.Rows.ApplyStyle(style, flag); workbook.Worksheets.Cells[0, 0].PutValue("First Row we Created");//row, col workbook.Worksheets.Cells.InsertRow(1); workbook.Worksheets.Cells[1,0].PutValue("Second Row we Created"); workbook.Save("RowPropertyPersists.xls");