creating an Excel Worksheet in C#.NET
I want to create an Excel worksheet with the details from a database and the important thing is the column names of the database should be displayed in the column headers of the excel sheet. for instance column names of an excel sheet is like this A B C D but for my program it must want to be displayed like UserName, Location, etc. please help me sir to get it done.
Darren KangPosted Jul 28, 2014, 5:24 AM
In short, it uses this .NET library to process excel files and you call a direct API (InsertDataTable) on the required worksheet.
Also notice the InsertDataTableOptions.ColumnHeaders property will indicate if the columns names will be imported as a header row (first row).
Sagar PardeshiPosted Jun 30, 2014, 1:46 AM
http://www.codedigest.com/Articles/ASPNET/400_ImportUpload_Excel_Sheet_data_to_Sql_Server_in_C__and_AspNet.aspx
Rahul PrasadPosted Jun 30, 2014, 12:43 AM
Arun Kumar RadhakrishnanPosted Jun 30, 2014, 12:18 AM
Arun Kumar RadhakrishnanPosted Jun 30, 2014, 12:15 AM
Rahul PrasadPosted Jun 29, 2014, 11:55 PM
refer this article - Export Data for database to Excel in C#
private void button1_Click(object sender, EventArgs e)
{
//connect database
OleDbConnection connection = new OleDbConnection();
connection.ConnectionString @"Provider=""Microsoft.Jet.OLEDB.4.0"";Data Source=""demo.mdb"";User Id=;Password="
OleDbCommand command = new OleDbCommand();
command.CommandText = "select * from parts";
DataSet dataSet = new System.Data.DataSet();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(command.CommandText,connection);
dataAdapter.Fill(dataSet);
DataTable t = dataSet.Tables[0];
//export datatable to excel
Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
sheet.InsertDataTable(t, true, 1, 1);
book.SaveToFile("insertTableToExcel.xls");
System.Diagnostics.Process.Start("insertTableToExcel.xls");
}
Sagar PardeshiPosted Jun 28, 2014, 9:42 AM
http://csharp.net-informations.com/excel/csharp-excel-export.htm