If you plan on getting a thr 'c # entry,
Instead of retrieving 10,000 or more records one at a time, select a specific number. e.g. 1000, 10 times. This will speed up the process and reduce the load on the memory.
You do not need to create a staging server table to store the dataset.
Using DocumentFormat.OpenXml.Spreadsheet in C #, you can write this dataset to Xlsx format or create an xml file using System.xml or use a third-party tool / create your own excel xml to create the xls format.
source share