ASP.NET 엑셀출력
//-- ASP.NET에서 엑셀출력하기
protected void btnExcel_Click(object sender, ImageClickEventArgs e)
{
if (ConditionInfoDataSet.Tables["Condition"].Rows.Count > 0)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=ExcelData.xls");
Response.Charset = "";
// If you want the option to open the Excel file without saving then
// comment out the line below
// Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
gvBubbleCall.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString().Replace("<td>", @"<td>=""").Replace("</td>", @"</td>"));
Response.End();
}
else if (ConditionInfoDataSet.Tables["Condition"].Rows.Count <= 0)
{
string sScript;
sScript = JavaScript.GetAlertScript("데이터가 없습니다.");
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Error", sScript);
}
}
'Development > .Net' 카테고리의 다른 글
Web Things Considered: DropDownList inside a GridView (or DataGrid) (0) | 2009.02.25 |
---|---|
엑셀 마지막 ROW, COLUMN COUNT (0) | 2009.02.25 |
Visual C#에서 Excel을 자동화하여 배열을 통해 일정 범위의 데이터를 채우거나 가져오는 방법 (0) | 2009.02.24 |
MSSQL 테이블 정보가져오기. (0) | 2009.02.24 |
Smart Clinet 개요 (0) | 2009.02.20 |