Epplus将值添加到一系列单元格中 [英] Epplus add values to a range of cells
本文介绍了Epplus将值添加到一系列单元格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C#中,使用 Microsoft.Office.Interop.Excel
,您可以一次将值分配给整个行:
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;
EPPlus库中是否提供任何类似的功能?
Is there any similar functionality provided in the EPPlus library?
推荐答案
您可以使用 .LoadFromCollection
方法。
因此,例如:
var vals = new string[] { "value1", "value2", "value3" };
var rng = sheet.Cells["A1:A3"];
rng.LoadFromCollection(vals);
将产生以下输出:
< a href = https://i.stack.imgur.com/1MSKzm.png rel = noreferrer>
这篇关于Epplus将值添加到一系列单元格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文