TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Robson Amaral
NA
132
17.3k
Get the index of the excel sheet line.
May 9 2018 1:38 PM
Friends, good afternoon! I have the following problem, before I used a "FOR" code in the meantime, to improve the performance of the application, I had to change my code to work with lines using DataRow, however, when working with foreach I can not plus grab the index value from my line. I have a excel sheet that I need to get index 6, because line 1 to 5 is header, however I tried to create several ways to create a counter, but take index 1 and not index 6 forward that would be correct. Could someone please help me?
when I used my "FOR" I could read line A6 ahead and the other columns:
for
(
int
i = 5; i <(numberLines - 1); i ++)
{
if
(process! =
null
)
{
// if the process is not null I search all procinter related to it
List <ProcessInterest> listprocinter = ProcessInterested.consultProcessor (process.Code);
if
(listprocinter.Exists (o => o.interest == interested))
//String.Concat (row.ToString ());
log.Append (
"The interested"
+ process.Interested.Name +
", entered in the line"
+ (i + 1) +
"was added again to the process"
+ process.NumProcesso +
""
);
//log.Append("The interested "+ process.Interested.Name +" was added back to the process "+ process.NumProcesso +" <br> ");
// log.Append ("The interested" + process.Interested.Name + "was added back to the process" + process.NumProcesso + "<br>");
setProcInter (process, interested, ds, row);
}
else
{
// New Process - 6.3
process =
new
Process ();
}
}
However, to improve performance I had to implement the foreach in place of the "FOR" and work with the DataRow and line. This is my changed code, but I can not get the index more correctly, can you please help me?
foreach
(var line
in
(IEnumerable <DataRow>) data)
{
if
(process! =
null
)
{
// if the process is not null I search all procinter related to it
List <ProcessInterest> listprocinter = ProcessInterested.consultProcessor (process.Code);
if
(listprocinter.Exists (o => o.interest == interested))
//String.Concat (row.ToString ());
log.Append (
"The interested"
+ process.Interested.Name +
", entered in the line"
+ (i + 1) +
"was added again to the process"
+ process.NumberProcess +
""
);
//log.Append("The interested "+ process.Interested.Name +" was added back to the process "+ process.NumberProcess +" <br> ");
// log.Append ("The interested" + process.Interested.Name + "was added back to the process" + process.NumberProcess + "<br>");
setProcInter (process, interested, ds, row);
}
else
{
// New Process - 6.3
process =
new
Process ();
process.Interested = interested;
}
}
Reply
Answers (
0
)
First Data Payment Gatway
MVC Data Entity Framework