EPPlus
EPPlus copied to clipboard
ExcelRange.Copy from a single cell to a range does not copy to all cells in range
When copying a cell to a range, the value in that cell does not get copied to all cells in the destination range - only to the first cell specified. This behavior is different to Excel - while not a huge problem, I thought I'd raise it as a possible quality of life enhancement if desired.
[TestMethod]
public void CopyCellToRange()
{
using (var pck = new ExcelPackage())
{
var sheet = pck.Workbook.Worksheets.Add("Sheet");
sheet.Cells["A1"].Value = 1;
var cellToCopy = sheet.Cells["A1"];
sheet.Cells["B1:B5"].Value = 2;
var destinationRange = sheet.Cells["B1:B5"];
cellToCopy.Copy(destinationRange);
for (var i = 1; i < 6; i++)
{
var actual = sheet.Cells[$"B{i}"]?.GetValue<int>();
Assert.AreEqual(1, actual, $"Expected 1 at B{i} but found the value {actual}.");
}
}
}
No, this is currently not the behavior of the Copy method, but I think we can look into changing this without breaking anything. I'll add this as an enhancement.