I have variables CompanyName,Expenditure,Total Value variables in the dictionary of the format New Dictionary(Of String, Tuple(Of String, String)) From {{“ABC”, New Tuple(Of String, String)(“1236”,“6786”)}} and so on…i want my output in excel as
Use Build Data Table Create an empty DataTable with columns “Company”, “Expenditure”, and “Total”.
For Each (Key-Value) in Dictionary: Iterate through the dictionary.
Add Data Row: Add a row to the DataTable for each company.
Company: Key
Expenditure: Value.Item1
Total: Value.Item2
Write the DataTable to an Excel file.
Try
Dim dictionaryValues = New Dictionary(Of String, Tuple(Of String, String)) From {{"1", New Tuple(Of String, String)("123","678")}}
dt.Columns.Add("Expenditure")
dt.Columns.Add("Total")
For Each kvp As KeyValuePair(Of String, Tuple(Of String, String)) In dictionaryValues
Dim dataRow As DataRow = dt.NewRow()
dataRow("Expenditure") = kvp.Key
dataRow("Total") = kvp.Value.Item1
dt.Rows.Add(dataRow)
Next
Catch
Catch ex As Exception
console.WriteLine(ex)
End Try