Insert a row with Validations

eg. I set validation for A1, when insert a row at row 1, A2 also keep the validations.

I would like to insert a blank row without any formats, need your help!

Hi,


Please use:

worksheet.Cells.InsertRow(0) for your needs.

In MS Excel, if you have data validation set on A1 cell, now if you would insert a row at row 1, the first row is shifted to row 2, hence the data validation would be on A2 now but the A1 has no validation as we have inserted a blank row at zero indexed position.

Thank you.


I just make an example to insert at A1, in fact my code like
cells.InsertRows(startRow, insertRows);

The startrow is dynamic, I don’t know which row is startRow, most of the time insertrows is fine, but sometimes there is a validation(dropdownlist) exist make my report have extra validations.

Hi,


I think when you preform the similar steps manually as per the Cells.InsertRows() method parameters at your specified location in your template file sheet, you will get the same results by MS Excel. Please try it and confirm us. If you have different results, please give us your template file and sample code that you are using to evaluate your issue on our end. Also provide your output Excel file and your expected file that you may manually create in MS Excel performing the steps as your code segments.

Thank you.

Yes, it is the same behavior with MS Excel, I just want to get some suggestions from you on how to deal with this problem.

Hi,


Yes, Aspose.Cells follows MS Excel standards while inserting row.

I think you may try to use Cells.ClearFormats () method with your specified parameters if it works for your needs.

Thank you.