CoderSource.net
Search
Export to excel
Started by puppyonline at 03-21-2006 1:46 AM. Topic has 1 replies.

Print Search « Previous Thread Next Thread »
   03-21-2006, 1:46 AM
puppyonline is not online. Last active: 3/21/2006 6:25:33 AM puppyonline

Top 75 Posts
Joined on 03-16-2006
Posts 1
Sad [:(] Export to excel
please lead me export dataTable to Excel.
and i don't know how insert data to dataTable.but data haven't in database.data is thing(exam:string ,int ,object...).

   Report 
   03-21-2006, 6:24 AM
Yasir is not online. Last active: 11/16/2006 10:02:40 AM Yasir

Top 10 Posts
Joined on 03-15-2006
Posts 44
Re: Export to excel
Hi

If you are creating a DataTable programmatically, you must first define its schema by adding DataColumn objects to the DataColumnCollection (accessed through the Columns property).
use following example code to create a dataTable and columns.

private void MakeTable(DataTable myTable){
// Create a DataTable.
DataTable myTable = new DataTable("myTable");
// Create a DataColumn and set various properties.
DataColumn myColumn = new DataColumn();
myColumn.DataType = System.Type.GetType("System.Decimal");
myColumn.AllowDBNull = false;
myColumn.Caption = "Price";
myColumn.ColumnName = "Price";
myColumn.DefaultValue = 25;
// Add the column to the table.
myTable.Columns.Add(myColumn);
// Add 10 rows and set values.
DataRow myRow;
for(int i = 0; i < 10; i++){
myRow = myTable.NewRow(); myRow["Price"] = i + 1;
// Be sure to add the new row to the DataRowCollection.
myTable.Rows.Add(myRow);
}
}

in this way you can create the data table.

Best Regards
-Yasir
   Report 
Codersource.Net » Programming » C# Programming » Export to excel

MENU
Home
MFC 
C++
.Net
WIN32
Programming
Forum
My Articles
Welcome to Codersource.Net Login | Register | Faq  

Google
 

NOTES:


Thanks for visiting our CoderSource.net. This site will be improved with more articles. Interested visitors can also submit their articles through the Submit Article link.Your article will also be published after due consideration by the editor. 

© Copyright 2003. All rights on content reserved by CoderSource.net. Contact    About Us