<%@page import="kr.co.kihyun.beans.totsys.report.ReportRegistManager"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
	import="java.net.URLEncoder"
	import="kr.co.kihyun.lang.Encoder" import="java.net.URLDecoder"
	import="kr.co.kihyun.lang.MString" import="kr.co.kihyun.lang.MLong"
	import="kr.co.kihyun.text.excel.Excel"
	import="kr.co.kihyun.text.html.HtmlUtil"
	import="kr.co.kihyun.lang.StringConverter"
	import="kr.co.kihyun.text.html.ServletUtil"
	import="kr.co.kihyun.moumi.Moumi"
	import="kr.co.kihyun.moumi.report.MReport"
	import="kr.co.kihyun.beans.user.Dept"
	import="kr.co.kihyun.beans.user.UserView"
	import="kr.co.kihyun.beans.totsys.doc.table.item.ItemList"
	import="kr.co.kihyun.beans.totsys.report.Report"
	import="kr.co.kihyun.beans.totsys.report.ReportView"
	import="kr.co.kihyun.beans.totsys.report.ReportViewManager"
	import="kr.co.kihyun.beans.totsys.report.ReportFormElement"
	import="kr.co.kihyun.text.hml.Hwp"
	import="kr.co.kihyun.text.html.HtmlUtil"
	import="kr.co.kihyun.text.html.TagFilter"
	import="javax.jdo.PersistenceManager" import="javax.jdo.Transaction"
	import="kr.co.kihyun.beans.entity.util.*"
	import="kr.co.kihyun.beans.entity.*"%>

<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>

<%
	//PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
	//Transaction tx = pm.currentTransaction();
	try
    {
		//Long docId = MLong.parseLong(request.getParameter("docId"),null);
		//TotDoc totDoc = pm.getObjectById(TotDoc.class, docId);
        //String formData=totDoc.getForm();
        request.setCharacterEncoding("UTF-8");
        response.setHeader("Context-Type", "text/html");
		response.setHeader("Accept-Ranges", "bytes");
        String formData=request.getParameter("outhtml");
        formData=URLDecoder.decode(formData, "UTF-8");
        //console.log(formData);
        //formData=new String(formData.getBytes("8859_1"),"UTF-8");
        //System.out.println(request.getCharacterEncoding()+"======================="+formData);

		String docname= request.getParameter("docname");
		String enc=request.getParameter("enc");
		if(enc!=null){
			response.setCharacterEncoding(enc);
		}
		if(docname==null){
			docname="temp";
		}else{
// 			docname=(URLEncoder.encode(docname, "UTF-8")).replaceAll(":","_").replace("+"," " );
			//docname=URLDecoder.decode(docname,"UTF-8");
			docname= docname.replaceAll(":","_").replace("+"," " );
		}
		if(request.getParameter("ishan")!=null){
			response.setHeader("Content-Disposition","attachment; filename="+docname+".hwp");
		}else{
			response.setHeader("Content-Disposition","attachment; filename="+docname+".xls");
		}
%>

<html xmlns:o="urn:schemas-microsoft-com:office:office"
      xmlns:x="urn:schemas-microsoft-com:office:excel"
      xmlns="http://www.w3.org/TR/REC-html40">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
        /*td {mso-number-format:"\@";}*/  // 엑셀저장시 문자로 취합하도록 설정
        .x124 {mso-number-format:"\@";}
        br {mso-data-placement:same-cell;} //엑셀저장시 BR을 같은 셀로 인식하도록 설정
    </style>
</head>
<body>
    <%=formData%>
</body>
</html>

<%
    } catch (Exception ex) {
    ex.printStackTrace();
    out.println(kr.co.kihyun.text.html.ServletUtil.getJavaScript("location='/servlet/kr.co.kihyun.beans.user.HttpSSOLogin?mode=logout';"));
    } finally {
    //pm.close();
    }
%>
