c# - C#如何使用foreach方法循环Excel命名范围
问题描述
我需要循环一些 Excel 数据,但每个文件中有 100 万个数据。
我尝试使用“for”和“Parallel.For”进行循环,但速度太慢,因此我想尝试使用 foreach 但我不知道如何制作。Parallel.For 代码如下:
Parallel.For(2, lastUsedRow, i =>
{
int AddValue = DValue + 1;
DValue = AddValue;
currentsheet.Cells[1, 1].Value = AddValue + "/" + lastUsedRow;
if (currentsheet.Cells[i, 3].Value != "")
{
currentsheet.Cells[i, 3].Value = Regex.Replace(currentsheet.Cells[i, 3].Text, "[ \\[ \\] \\^ \\-_*×――(^)(^)$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", "");
currentsheet.Cells[i, 3].Value = currentsheet.Cells[i, 3].Text.ToUpper();
currentsheet.Cells[i, 3].Value = currentsheet.Cells[i, 3].Text.Replace(" ", "");
}
else
{
currentsheet.Cells[i, 3].Value = "";
}
string COLVALUE = currentsheet.Cells[i, 3].Text;
if (Regex.Matches(COLVALUE, "[a-zA-Z]").Count != 0 & COLVALUE.Length != 12)
{
currentsheet.Cells[i, 3].Value = "";
currentsheet.Cells[i, 4].Value = COLVALUE;
}
});
这里的每个朋友都知道如何在行范围或命名范围内进行 foreach 循环吗?非常感谢。
解决方案
推荐阅读
- c# - 如何阻止 ComboBox 在 Ctrl-Enter 上打开?
- arrays - netlogo:数组问题:来自列表(过滤器
- python-3.x - How would I change this tuple back into string to be written in a file?
- gradle - 错误:Gradle 5.0 中删除了对使用低于 3.0 的工具 API 版本的客户端的支持
- windows - Windows Server 2016 1607 上的 Windows 容器中的 Jenkins
- r - How to convert the output from readLines into a dataframe
- rest - 如何在 Drupal 8 中对自定义插件(资源)自动应用更改更改
- mobile - P2P messaging over internet
- php - 动态产品列表页面php
- php - Laravel 5.7.28 覆盖 getAuthPassword 仍然会引发未定义的索引:密码