关于函数调用,我有一个理解问题。我在“excel”类中的第一个功能是查找名称为“* ID *”的单元格。
public IEnumerable<string> FindID()
{
try
{
while (true)
{
if (ws.Cells[i, j].Value2 == "*ID*")
{
string ID = ws.Cells[i, j].Value2;
yield return ID;
yield break;
}
else
{
i++;
if (ws.Cells[i, j].Value2 == "*MAIN INFO END*")
{
i = 1;
j++;
}
}
}
}
finally
{
}
}
我的第二个函数循环放置在字符串中的列,例如“名称”或“可搜索”以查找列中的所有值并将所有值连接到每行的唯一字符串中。
public IEnumerable<string> AttributeToForm(int i, int j)
{
try
{
while (true)
{
if (ws.Cells[i, j].Value2 != null)
{
FindID();
string label = ID;
string name = ws.Cells[i, j + 1].Value2;
string searchable = ws.Cells[i, j + 3].Value2;
string FormField = "<FormField :span=\"6\" data-bwid =\"" + name + "\" name=\"" + name + "\" label=\"" + label + "\" ";
if (searchable != null) {
FormField += string.Join("", "searchable");
}
if(FormField != null)
{
FormField += string.Join("", "/>" + "\n");
}
else
{
}
yield return label;
i++;
}
else
{
yield break;
}
}
}
finally
{
}
}
但是......我真正想要的是在我的'AttributeToForm'函数中使用我的'FindID'函数中包含的字符串'ID'。为了到达那里,我尝试运行“FindID”函数并检索ID字符串。然而,结果仍然是我的类"ID"字符串,所以"nothing"。
class Excel
{
private int i = 1;
private int j = 1;
private string ID = "nothing";...


