Hi,
I have one excel sheet named Sheet1, there is some data like;
Sr.No Particular Mail_ID
1. abc [email protected]
2. def [email protected]
3. ghi [email protected]
4. jkl [email protected]
But, I want that data in other Excel sheet like;
Sr.No 1 2 3 4
Particular abc def ghi jkl
Mail_ID [email protected] [email protected] [email protected] [email protected]
So, how should I do this using C# ASP.NET 3.5 ?
Loading

Posted Jun 9, 2011, 2:11 AM
{
DataTable dest = new DataTable();
dest.Columns.Add( "Sr.no" );
foreach( DataRow r in source.Rows )
{
dest.Columns.Add( r[0].ToString() );
}
for( int i = 1; i < source.Columns.Count ; i++ )
{
DataRow fila = dest.NewRow();
fila[0] = source.Columns[i].ColumnName;
dest.Rows.Add( fila );
}
for( int fil = 0; fil < source.Rows.Count; fil++ )
{
for( int col = 1; col < source.Columns.Count ; col++ )
{
dest.Rows[col-1][fil+1] = source.Rows[fil][col];
}
}
dest.AcceptChanges();
return dest;
}
Hop this helps you.
Posted Jun 9, 2011, 3:17 AM
Sahil JaniPosted Jun 9, 2011, 2:47 AM
Ohki, I will try and let you know if I will get any error on that code.
And once again thank you so much for helping me.
Posted Jun 9, 2011, 2:42 AM
Sahil JaniPosted Jun 9, 2011, 2:27 AM
Thanks for giving code. But I want that code in asp.net and I'm new to this so I don't know how to write this windows application code in web application.
Please help.
Posted Jun 9, 2011, 2:14 AM