As far as I know, there're 3 ways to do this:
- The first way is using COM Interop to create a Excel file, then iterate over all cells to read and write data. The created file appears to be valid (true .XLS file), but it seems that Excel must installed to use this way
- The second way is writing a file header (CSS style), and then iterate over all cells, too. This way doesn't requires Excel installed, but the file created may not be valid (it's a HTML file, actually)
- The third way is fill DataTable into a DataGrid, and then render it into a HTML file, then rename it into .xls extension.
The third way seems to be simplest, but I don't know if there is a better way to archive this? If not, which is the best in these three ways?
Thank you so much.