I found a nice post on StackOverflow for exporting data from IEnumerable to CSV. You can able to find the post here.
Now Visual Studio 2022 has built in IEnumerable Visualizer in it.

Also it has a ‘Export to Excel’ button from where you can export the data to excel.
