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

Free Support Forum - aspose.com

Insert new rows has format/properties persist from the previous row

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.InsertRow() or 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[0].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[0].Cells.Rows[0].ApplyStyle(style, flag);
        workbook.Worksheets[0].Cells[0, 0].PutValue("First Row we Created");//row, col

        workbook.Worksheets[0].Cells.InsertRow(1);

        workbook.Worksheets[0].Cells[1,0].PutValue("Second Row we Created");

        workbook.Save("RowPropertyPersists.xls");

@dfactset,

I have observed this issue by executing the sample code. In the recent release 19.2 we have introduced a new feature where “CopyFormatType.Clear” can be used while inserting rows. Due to some reason this feature is not working, therefore we have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46609 - Insert option CopyFormatType.Clear not working properly  

Following is the sample code with this new feature:

Workbook workbook = new Workbook();

workbook.Worksheets[0].Cells.InsertRows(0, 1);

var style = workbook.CreateStyle();
var flag = new StyleFlag();

style.Font.IsBold = true;
flag.FontBold = true;

workbook.Worksheets[0].Cells.Rows[0].ApplyStyle(style, flag);
workbook.Worksheets[0].Cells[0, 0].PutValue("First Row we Created");//row, col

workbook.Worksheets[0].Cells.InsertRows(1,1,new InsertOptions() { CopyFormatType = CopyFormatType.Clear});

workbook.Worksheets[0].Cells[1, 0].PutValue("Second Row we Created");// THIS TEXT SHOULD NOT BE BOLD AS CLEAR IS USED ABOVE

workbook.Save(path + "RowPropertyPersists.xls");

@dfactset,

This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-46609”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@dfactset,

Please try our latest version/fix: Aspose.Cells for .NET v19.2.3 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells19.2.3 For .Net2.Zip (4.7 MB)
Aspose.Cells19.2.3 For .Net2_AuthenticodeSigned.Zip (4.8 MB)
Aspose.Cells19.2.3 For .Net4.0.Zip (4.8 MB)

The issues you have found earlier (filed as CELLSNET-46609) have been fixed in Aspose.Cells for .NET v19.3. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi