Search code examples
c#epplusepplus-4

How to insert a row in one go with EPPlus


I've started using EPPlus and I was wondering if there is a way to insert a row all in one go instead of having to populate cell by cell.

For example let's say my row number 6 is populated with various number, could I insert all cells in the row by separating the values with something like a comma or a tab? Something like:

ws.Row(6).Value = "12,45,76,12,1";

(I know the syntax above doesn't work, just wondering if there is a way to do something similar). Thank you!


Solution

  • You mean like this:

    ws.Cells[6, 1].LoadFromText("12,45,76,12,1");
    

    The Cells object has an overload to specify Row, Column. LoadFromText has 5 overloads so you can get very specific on how it loads the text. The above will give this:

    enter image description here