reading and returning specific data and define it in different cells

kwood30

Member
Joined
Feb 25, 2018
Messages
6
Programming Experience
Beginner
Hi,

I have managed to sort out a lot that I asked about in my last post.

What I am now trying to do, I just read the first row, column 1 to 9, define that each of these cells contain specific data. After this I am then trying to class these particular cells as headers, then when I move on to look through more rows, If they don't contain this specific data, but still contain a value then still read it but it returns not as a header. By doing this I am using it to define if the cells contain either a header or another value. Hope this makes sense.

The code I have come up with is simple but I don't know how to go around to define if its a header or not.

C#:
If (!string.IsNullOrEmtpy(colValue))
               isBlankRow = false;

     If (!IsHeadingValue(colValue))
              isHeadingRow = false;
 
Hi Sorry,

An excel file. I have also come up with the fact that each row will either have this heading information or others values, so can I do the first row of headers, then check the first cell of the second row, if it doesn't match cell 1 row 1 then not a header but if contains other values return valid, if its blank then return blank, if anything else is invalid?
This below is what I have written so far;

C#:
private RowType ConvertExcelRowToCVS(Range row, out CVS cvs)
        {
            cvs = new CVS();

           
            int startCol = 1;
            int endCol = 9;    

            for (int x = startCol; x <= endCol; x++)
            {
                
                var colValue = row.Cells[1, x].Value;


                if (string.IsNullOrEmpty(colValue))
                {
                    return RowType.Blank;
                }

                if (isHeadingValue(colValue))
                {
                    return RowType.Header;
                }

                if (isValue(colValue))
                {
                    return RowType.Valid;
                }
                if (!isHeaderValue || !isValue (colValue))
                {
                    return RowType.Invalid
                }
                  
            }
 
Last edited:
Back
Top Bottom