티스토리 뷰

반응형

protected void SaveExcel()
    {
        Response.Clear();
        //Excel파일 저장
        Response.ContentType = "application/vnd.ms-excel; name='My_Excel'";
        Response.AddHeader("content-disposition", "attachment;filename=ISBNFindLib.xls");
        Response.AddHeader("content-description", "ASP Generated Data");
        //Response.ContentType = "application/vnd.ms-excel; name='My_Excel'";
       
       
        //Word파일 저장
        /*
        Response.AddHeader("content-disposition", "attachment;filename=ISBNFindLib.doc");
        Response.ContentType = "application/vnd.word";
         */

        StringWriter stringWriter = new StringWriter();
        System.Web.UI.HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
        DataGrid1.RenderControl(htmlWriter);

        string strStyle = @"<style>td{mso-number-format:\@;} </style>";//숫자를 string형으로 전환해서 저장

        Response.Write(strStyle);
        Response.Write(stringWriter.ToString());
        Response.End();
    }

반응형

'Programming > JAVA' 카테고리의 다른 글

안드로이드 개발툴 설치하기  (0) 2013.03.02
Eclipse Heap 영역 넓히기  (0) 2013.02.26
JAVA DeComplier  (0) 2009.08.11
jsp & JAVA 코딩 가이드(펌)  (0) 2009.08.10
서울 자바 FX관련 세미나  (0) 2009.05.25
공지사항