// pass a Page reference and dataset as parameters from an ASP.net page createexcel oexcel = new createexcel(this,localds); // include files for your class using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; namespace mynamespace { public class createexcel { public createexcel(Page opage,DataSet odataset) { string strFile ="c:\\report" + System.DateTime.Now.Ticks.ToString(); if (odataset.Tables[0].Rows.Count>0) { StreamWriter sw = new StreamWriter(strFile+".txt"); sw.Write("<html>"); sw.Write("<head>"); sw.Write("<title>ASP.NET Excel Sample</title>"); sw.Write("</head>"); sw.Write("<body>"); sw.Write("<table>"); sw.Write("<thead>"); sw.Write("<tr>"); for(int x=0;x<odataset.Tables[0].Columns.Count;x++) { sw.Write("<th bgcolor='blue'><font color='white'>"+odataset.Tables[0].Columns[x].ColumnName.ToString()+"</font></th>"); } sw.Write("</tr>"); sw.Write("</thead>"); for(int x=0;x<odataset.Tables[0].Rows.Count;x++) { sw.Write("<tr>"); for(int y=0;y<odataset.Tables[0].Columns.Count;y++) { sw.Write("<td>"+odataset.Tables[0].Rows[x][y].ToString()+"</td>"); } sw.Write("</tr>"); } sw.Write("</tbody>"); sw.Write("</table>"); sw.Write("</body>"); sw.Write("</html>"); sw.Close(); FileStream MyFileStream = new FileStream(strFile+".txt", FileMode.Open); long FileSize; FileSize = MyFileStream.Length; byte[] Buffer = new byte[(int)FileSize]; MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length); MyFileStream.Close(); System.IO.File.Delete(strFile+".txt"); opage.Response.ContentType="application/vnd.ms-excel"; opage.Response.AddHeader( "content-disposition","attachment; filename=MyXLS.XLS"); opage.Response.BinaryWrite(Buffer); } // // TODO: Add constructor logic here // } } }>Tks, Eric. I'll look into those.