I have a code for getting the csv from datatable . But i can't save the csv formatted file. How can I save ?
File.WriteAllText("test.csv", sb.ToString());
This is not working?
I have a code for getting the csv from datatable . But i can't save the csv formatted file. How can I save ?
File.WriteAllText("test.csv", sb.ToString());
This is not working?
Why aren't u using xls or xlsx instead of csv? If you want to use xls or xlsx you can look at nopcommerce opensource projects source code. You can download it from
And then open the project with
visual studio 2012
Go to Nop.Services project under Libraries solution folder. There is a folder in this project named "ExportImport" you can look at the codes.
But if you want csv you can look at following posts
Write to CSV file and export it?
How to create CSV Excel file C#?
https://stackoverflow.com/questions/12418520/jquery-c-sharp-export-to-csv
http://www.codeproject.com/Articles/8411/C-class-library-for-exporting-data-to-CSV-Excel-fi