So what ı have to do is read the datatable, take the name column ones (labels). Compare them with dynamic excel column names. If ıt matches, write the second column values from dt to excel.
For example in this case. I have “Renk” label in my dynamic dt and dynamic excel column. I have to write the “Açık Kırmızı” value to excel’s “Renk” column.
For Each col As DataColumn In dtExcel.Columns
If dtSource.Columns.Contains(col.ColumnName) Then
idx = dtSource.Columns.IndexOf(col.ColumnName)
For Each row As DataRow In dtSource.Rows
value = row(idx).ToString()
' Assuming columns in Excel start at row 2
cellAddress = col.ColumnName + (dtSource.Rows.IndexOf(row) + 2).ToString()
' Write value to Excel
Write Cell
Input: filepath, SheetName: "Destination", Cell: cellAddress, Value: value
Next
End If
Next
The error states that Columns is not a member of String. This means that dt_attribute is of Type String. Please change the data type of dt_attribute to DataTable.
Thank you. it fixed the error says “not a member of string” but ı have the other one, do you have an idea ? Could you help me please ? @ashokkarale@V_Roboto_V