Hi,
I just wanna know that is there any easy way to copy a Datatable's data(or Dataset) to an Excel file? My codes are below;
------------
SqlConnection bag_sql = new SqlConnection("Data Source=Mega;Initial Catalog=Config;User Id=WindsCm;Password=1abc;");
bag_sql.Open();
OleDbConnection bag_excel = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=hw.xlsx;Extended Properties=Excel 12.0 Xml;");
bag_excel.Open();
String query_router="SELECT * FROM Node WHERE Node_City='NY'";
SqlDataAdapter oadp = new SqlDataAdapter(query_router, bag_sql);
DataTable tbl_router = new DataTable();
oadp.Fill(tbl_router);
...
---------------
Loading
navjyot rautPosted Oct 25, 2011, 6:26 AM
Setting for running the project
1.Right click the project and select propertise
2.Check the "Enable running application out of browser checkbox".
TulasiPosted Oct 25, 2011, 5:18 AM
As far as I know, if you want to export to Excel from dataset directly, it has some disadvantages which contain data format problem, export format problem, etc. So I suggest you try the codes to export excel from gridview. It's the common approach and it is better than exporting from dateset directly. You can create GridView bound by dataset to achieve.
1) http://www.c-sharpcorner.com/Forums/Thread/144888/export-to-excel-from-gridview-in-Asp-Net-form.aspx
2) http://forums.asp.net/t/1197704.aspx/1