public class DataSetToExcel
{
public DataSetToExcel(){}
public void Convert(DataSet oDS,HttpResponse Response)
{
Response.Clear();
Response.Charset = "big5";
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter oSW = new System.IO.StringWriter();
HtmlTextWriter oHW = new HtmlTextWriter(oSW);
DataGrid oDG = new DataGrid();
oDG.DataSource = oDS.Tables[0];
oDG.DataBind();
oDG.RenderControl(oHW);
Response.Write(oSW.ToString());
Response.Flush();
Response.Close();
}
public void Convert(DataSet oDS,HttpResponse Response,string sCharSet)
{
Response.Clear();
Response.Charset = sCharSet;
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter oSW = new System.IO.StringWriter();
HtmlTextWriter oHW = new HtmlTextWriter(oSW);
DataGrid oDG = new DataGrid();
oDG.DataSource = oDS.Tables[0];
oDG.DataBind();
oDG.RenderControl(oHW);
Response.Write(oSW.ToString());
Response.Flush();
Response.Close();
}
}