c# - 使用范围 C# 将字符串列表写入 excel
问题描述
我有一个excel范围:
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?
解决方案
您可能需要对此进行调整并修复一些小问题,但它应该可以解决问题(使用 EPPlus):
int counter = 1;
foreach (string str in AcollumnValues) {
worksheet.Cells["A" + counter].Value = str;
counter++;
}
推荐阅读
- java - 如何将字符串 JSON 值带入 HashMap
- scala - 无法解析符号 mllib
- c++ - 使用 std::vector 保存 BMP 像素图
- javascript - 在 React 中更新父级状态时如何更新子级中的道具?
- r - 在 mlr 中调整 h2o 超参数?
- scala - 将字符串格式的科学记数法转换为 Spark 数据框中的数字
- c# - 使用 NEST 将文档自动映射到弹性搜索中不起作用
- c# - 当我在计时器中使用 xlApp.CutCopyMode 时,我的应用程序不会关闭。为什么会这样?
- android - 何时使用 MutableLiveData 和 LiveData
- ffmpeg - 如何修复输出流 0:1 中的非单调 DTS;使用 ffmpeg 时