Search code examples
c#epplusepplus-4

EPplus To Insert X Number of Blank Rows


I have an instance where if a cell value is between 15 and 25 then I need to insert 10 blank rows, if the cell value is > 30 I need to insert 25 blank rows

Rather than simply typing the same syntax repeatedly and adding 1 row at a time, does EPPLUS have a function of adding X rows at one time?

This works but will be lots of code repeated:

ws.InsertRow(31, 31, 1);

Solution

  • The method you are using already takes care of that.

    w.InsertRow(10, 15);
    

    This will insert 15 rows starting at row 10. All the rows under will be shifted down.

    The actual method signature:public void InsertRow(int rowFrom, int rows);