I need to compare A1 with B1 and C1 and other column names also in excel…if any two column names are equal… i need to modify the duplicate column name to other name…if any one have the solution help me…
Is there any particular reason why you wouldn’t want to load your Excel file into a Data Table?
- Load Excel into Data Table
- Do the comparisons
- Modify the names of other columns by using the Write Cell activity
It looks to me like the best approach.
If excel has duplicate column names, we cant read that excel then how we can load it into datatable?
Correct me if i am wrong?
if we use Data table we will get duplicate column name exception…
Indeed, but there are ways out of it
You could load it without considering the first row as column headers (uncheck it in the Read Range activity).
This will load the column names as a normal row in Data Table, while assigning internal column names as Column0, Column1, and so on
If you output it to the console, you will see something like this:
for an input like this:
@sindhura506 Not sure useful or not check attached zip file for reference
DuplicateColumn.zip (7.9 KB)
i need headers also…if i uncheck headers based on that headers i’m getting values of particular cell
You will also get the values of your headers copied into the Data Table, but as normal values in the first row. You can then act accordingly.
@sindhura506 Find the attached workflow it will solve ur problem mostly.
expNew.xaml (16.0 KB)
Reference excel sheet is attached below, You can find the output in Sheet2.
new.xlsx (8.7 KB)
In the mentioned code, what is the initial value of variable count as i am not able to understand the condition “count<dt.Columns.Count-1”
Instead of using row.item(colname) you can n use row.item(datatable.rows(0). item(index))
@pruthvisiddhartha count variable initial value is 0.