Skip to content

Fill ranges

Mats Alm edited this page Aug 8, 2023 · 12 revisions

EPPlus 5.8 adds three methods to the ExcelRangeBase class to fill values.

  • FillNumber
  • FillDateTime
  • FillList

The code below comes from sample 30 for .NET Core/.NET Framework

FillNumber

FillNumber fills a range with numbers.

ws.SetValue("A1",50);
//FillNumber with no parameters will fill the range using the value in the top-left cell as start value and increment it by 1 for each cell in the column. If the range has multiple columns the first value in the column will be used as start value.
ws.Cells["A1:A20"].FillNumber();

You can add a number of parameters to this method like initial value, increment and more. Here are a few samples:

//Fill with a start value of 30 and decrease by 2.
ws.Cells["B1:B20"].FillNumber(30, -2);