I have a table in excel that I need to read and extract the headers. I have a problem: sometimes, I have columns that have the same name. So, my idea is:
1 - read first row;
2 - see if I have duplicated strings (comparing the lenght with the different strings);
3 - if yes, add a digit in the end of each string, overwrite in the excel and the read the table.
However, I don’t know how to change the type of variables: from the first step, I will have a inumerable, and I want to change it to array of strings.
I know that I could read the table without the headers option (and the duplication aren’t a problem anymore), but I need to have that option on for other parts of my flow.
When you read the header row, you can convert the rows to elements of a List by iterating over row.Table.Columns. For each column Col, add the column to the list with row(Col).
Now you can use this list to check for duplicates and perform your renaming options.
You can simply put a ToArray() after the output variable of the read row and you will get the array, but will be as object, to read the values you can then use .ToString in each item.
i dont see why not… objects are like generic types, they will actually be string anyway…
but you can convert to string array like this if preferred: stringArray = linha.[Select](Function(x) x.ToString()).ToArray()