我有这个当前函数,它在迭代表中时清除第2列值等于-1的行。我遇到的问题是我不想检查表中的最后一行。我怎么能这样做?
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
...
PostMethod post = new PostMethod(getURI(data.getAttributes(), targetUri));
...
HttpClient httpclient = new HttpClient();
...
int result = httpclient.executeMethod(post);
OLD VBA代码我正在尝试转换为C#
foreach (Excel.ListRow lr in xlWorkBook.Worksheets["Sheet1"].ListObjects["table1"].ListRows)
{
CurrentRow = CurrentRow + 1;
if (xlWorkBook.Worksheets["Sheet1"].ListObjects["table1"].Range[CurrentRow, 2].value == -1)
{
lr.Range.Clear();
//CALL MoveEmUP
//ListRow = ListRow - 1? I'd like to possibly do something like this.
}
所以,我试图让它定义后跟“MoveEmUp” 被叫。
答案 0 :(得分:1)
用于循环。 Count属性将返回集合中的行数,指定count-2使其从0到lastOne-1。
var listRowsValue = WorkBook.Worksheets["Sheet1"].ListObjects["table1"].ListRows;
for(int i=0; i < listRowsValue.Count - 2; i++)
{
//do your stuff;
var lr = listRowsValue[i];
}