In C#, using Microsoft.Office.Interop.Excel
, you can assign values to an entire row at once like this:
string[] headings = { "Value1", "Value2", "Value3" };
excelSheet.get_Range("A1:C1", Type.Missing).Value2 = headings;
Is there any similar functionality provided in the EPPlus library?
A little clunky but here is an example.
// A row of numbers
var numbers = new List<object> {1.1, 2.2, 3.3};
var horizontalRange = sheet.Cells[$"A1:A{numbers.Count}"];
horizontalRange.LoadFromArrays(new List<object[]> {numbers.ToArray()});
// a grid
var colours = new object[] { "red", "green", "blue"};
var range2d = sheet.Cells["A3:C4"];
range2d.LoadFromArrays(new List<object[]> { numbers.ToArray(), colours });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.