我有一个出色的范围:
Excel.Range range = Worksheet.get_Range("A1","A7");
还有一个字符串列表:
// The list contains the same amount of elements as cells in the range
List<string> AcollumnValues = getList();
到目前为止,我的代码:
Excel.Application App = new Excel.Application();
Excel.Workbook Workbook = App.Workbooks.Open(sourceASettings["file"]);
Excel._Worksheet Worksheet = Workbook.Sheets[1];
Excel.Range range = Worksheet.get_Range("A1","A4") userSupliedRangeArray[1]);
List<string> valuesToWrite = getValuesToWrite();
如何使用范围将字符串列表写入excel?
答案 0 :(得分:3)
您可能需要对此进行调整并解决一些小问题,但这应该可以解决问题(使用EPPlus):
int counter = 1;
foreach (string str in AcollumnValues) {
worksheet.Cells["A" + counter].Value = str;
counter++;
}