📄 reviewexcel.jsp
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" contentType="text/html; charset=gbk" %>
<%@ page import="com.doone.fj1w.fjmgr.research.ResearchBean"%>
<%@ page import="com.doone.util.*"%>
<%@ page import="com.doone.data.*"%>
<%@ page import="com.doone.uurm.*"%>
<%!
String getHTMLString(String tmp) {
tmp = tmp.replaceAll("\'","'");
tmp = tmp.replaceAll("\"", """);
tmp = tmp.replaceAll("<", "<");
tmp = tmp.replaceAll(">", ">");
tmp = tmp.replaceAll("&", "&");
return tmp;
}
%>
<%
WebAuth auth = WebAuth.getInstance(request);
if ( ! auth.IsAuthed() ) {
out.write("<script language=\"javascript\">self.parent.location.replace(\"" + request.getContextPath() + "/view/login/login.jsp" + "\");</script>");
return;
}
// 获取参数
String researchId = request.getParameter("id");
String openMode = request.getParameter("OPENMODE");
String researchName = request.getParameter("researchName") ;
String sTitle = "" ;
if ( researchId == null) {
out.write("<script language=javascript>window.location.href='"+request.getContextPath() + "/view/research/ResearchMain.jsp?error=参数不正确!';</script>");
return;
}
if ( researchName == null) {
out.write("<script language=javascript>window.location.href='"+request.getContextPath() + "/view/research/ResearchMain.jsp?error=参数不正确!!';</script>");
return;
}
StringBuffer buffer = new StringBuffer();
try {
ResearchBean rb = new ResearchBean() ;
DataTable dt = rb.getRearchReview(researchId) ;
StringBuffer content = new StringBuffer();
sTitle = researchName.substring(0,researchName.indexOf("<SPAN")) ;
sTitle = sTitle + "的评论列表" ;
if ( openMode == null) {
content.append("<ss:Row>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\">调查主题</ss:Data>\n</ss:Cell>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\">"+getHTMLString(sTitle)+"</ss:Data>\n</ss:Cell>\n");
content.append("</ss:Row>\n");
content.append("<ss:Row>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\">评论时间</ss:Data>\n</ss:Cell>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\">评论内容</ss:Data>\n</ss:Cell>\n");
content.append("</ss:Row>\n");
content.append("<ss:Row>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\"></ss:Data>\n</ss:Cell>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\"></ss:Data>\n</ss:Cell>\n");
content.append("</ss:Row>\n");
//content.append("<ss:Row>\n");
// 评论时间
//content.append("<ss:Cell><ss:Data ss:Type=\"String\">");
//content.append("评论时间");
//content.append("</ss:Data></ss:Cell>\n");
// 评论内容
//content.append("<ss:Cell><ss:Data ss:Type=\"String\">");
//content.append("评论内容");
//content.append("</ss:Data></ss:Cell>\n");
//content.append("</ss:Row>\n");
int index = 0;
while ( index < dt.getRows().getCount() ) {
content.append("<ss:Row>\n");
String REVIEWCONTENT = dt.getRow(index).getString("REVIEWCONTENT");
REVIEWCONTENT = REVIEWCONTENT.substring(
REVIEWCONTENT.indexOf("[/img]") + 6,
REVIEWCONTENT.length());
// 评论时间
content.append("<ss:Cell><ss:Data ss:Type=\"String\">");
content.append(dt.getRow(index).getString("REVIEWTIMER"));
content.append("</ss:Data></ss:Cell>\n");
// 评论内容
content.append("<ss:Cell><ss:Data ss:Type=\"String\">");
content.append(getHTMLString(REVIEWCONTENT));
content.append("</ss:Data></ss:Cell>\n");
content.append("</ss:Row>\n");
index++;
}
buffer.append("<?xml version=\"1.0\"?>\n");
buffer.append("<ss:Workbook xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n xmlns:c=\"urn:schemas-microsoft-com:office:component:spreadsheet\">\n ");
buffer.append("<x:ExcelWorkbook>\n");
buffer.append("<x:ProtectStructure>False</x:ProtectStructure>\n");
buffer.append("<x:ActiveSheet>0</x:ActiveSheet>\n");
buffer.append("</x:ExcelWorkbook>\n");
buffer.append("<ss:Styles>\n");
buffer.append("<ss:Style ss:ID=\"Default\">\n ");
buffer.append("<ss:Alignment ss:Horizontal=\"Automatic\" ss:Rotate=\"0.0\" ss:Vertical=\"Bottom\"\n ss:ReadingOrder=\"Context\"/>\n");
buffer.append("<ss:Borders>\n</ss:Borders>\n");
buffer.append("<ss:Font ss:FontName=\"宋体\" ss:Size=\"10\" ss:Color=\"Automatic\" ss:Bold=\"0\"\n ss:Italic=\"0\" ss:Underline=\"None\"/>\n");
buffer.append("<ss:Interior ss:Color=\"Automatic\" ss:Pattern=\"None\"/>\n");
buffer.append("<ss:NumberFormat ss:Format=\"General\"/>\n");
buffer.append("<ss:Protection ss:Protected=\"1\"/>\n");
buffer.append("</ss:Style>\n");
buffer.append("<ss:Style ss:ID=\"wc0CEFE34C\">\n");
buffer.append("<ss:Alignment ss:Horizontal=\"Center\"/>\n");
buffer.append("<ss:Font ss:FontName=\"宋体\" ss:Size=\"10\" ss:Bold=\"1\"/>\n");
buffer.append("</ss:Style>\n");
buffer.append("</ss:Styles>\n ");
buffer.append("<c:ComponentOptions>\n");
buffer.append("<c:Label>\n");
buffer.append("<c:Caption>Microsoft Office Spreadsheet</c:Caption>\n");
buffer.append("</c:Label>\n ");
buffer.append("<c:MaxHeight>80%</c:MaxHeight>\n ");
buffer.append("<c:MaxWidth>80%</c:MaxWidth>\n ");
buffer.append("<c:NextSheetNumber>4</c:NextSheetNumber>\n ");
buffer.append("</c:ComponentOptions>\n ");
buffer.append("<x:WorkbookOptions>\n ");
buffer.append("<c:OWCVersion>10.0.0.4109</c:OWCVersion>\n");
buffer.append("<x:Height>7620</x:Height>\n");
buffer.append("<x:Width>15240</x:Width>\n");
buffer.append("</x:WorkbookOptions>\n");
buffer.append("<ss:Worksheet ss:Name=\""+getHTMLString(sTitle)+"\">\n ");
buffer.append("<x:WorksheetOptions>\n ");
buffer.append("<x:Selected/>\n ");
buffer.append("<x:ViewableRange>R1:R262144</x:ViewableRange>\n ");
buffer.append("<x:Selection>R1C1</x:Selection>\n ");
buffer.append("<x:TopRowVisible>0</x:TopRowVisible>\n ");
buffer.append("<x:LeftColumnVisible>0</x:LeftColumnVisible>\n ");
buffer.append("<x:ProtectContents>False</x:ProtectContents>\n ");
buffer.append("</x:WorksheetOptions>\n ");
buffer.append("<c:WorksheetOptions>\n </c:WorksheetOptions>\n ");
buffer.append("<ss:Table ss:DefaultColumnWidth=\"54.0\" ss:DefaultRowHeight=\"12.75\">");
buffer.append("<ss:Column ss:Width=\"300.0\" ss:AutoFitWidth=\"0\"/>");
buffer.append("<ss:Column ss:Width=\"120.0\" ss:AutoFitWidth=\"0\"/>");
buffer.append("<ss:Column ss:Width=\"54.0\" ss:AutoFitWidth=\"0\"/>");
buffer.append("<ss:Column ss:Width=\"100.0\" ss:AutoFitWidth=\"0\"/>");
buffer.append("<ss:Column ss:Width=\"250.0\" ss:AutoFitWidth=\"0\"/>");
buffer.append(content);
buffer.append("</ss:Table>\n</ss:Worksheet>\n");
buffer.append("</ss:Workbook>\n");
ExtString.replace(buffer, "&", "&");
ExtString.replace(buffer, "<", "<");
ExtString.replace(buffer, ">", ">");
ExtString.replace(buffer, "\"", """);
}
else {
content.append("<ss:Row>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\">调查主题</ss:Data>\n</ss:Cell>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\">"+getHTMLString(sTitle)+"</ss:Data>\n</ss:Cell>\n");
content.append("</ss:Row>\n");
content.append("<ss:Row>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\">评论内容</ss:Data>\n</ss:Cell>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\">评论时间</ss:Data>\n</ss:Cell>\n");
content.append("</ss:Row>\n");
content.append("<ss:Row>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\"></ss:Data>\n</ss:Cell>\n");
content.append("<ss:Cell ss:StyleID=\"wc0CEFE34C\"><ss:Data ss:Type=\"String\"></ss:Data>\n</ss:Cell>\n");
content.append("</ss:Row>\n");
//content.append("<ss:Row>\n");
// 评论时间
//content.append("<ss:Cell><ss:Data ss:Type=\"String\">");
//content.append("评论时间");
//content.append("</ss:Data></ss:Cell>\n");
// 评论内容
//content.append("<ss:Cell><ss:Data ss:Type=\"String\">");
//content.append("评论内容");
//content.append("</ss:Data></ss:Cell>\n");
//content.append("</ss:Row>\n");
int index = 0;
while ( index < dt.getRows().getCount() ) {
content.append("<ss:Row>\n");
String REVIEWCONTENT = dt.getRow(index).getString("REVIEWCONTENT");
REVIEWCONTENT = REVIEWCONTENT.substring(
REVIEWCONTENT.indexOf("[/img]") + 6,
REVIEWCONTENT.length());
// 评论内容
content.append("<ss:Cell><ss:Data ss:Type=\"String\">");
content.append(getHTMLString(REVIEWCONTENT));
content.append("</ss:Data></ss:Cell>\n");
// 评论时间
content.append("<ss:Cell><ss:Data ss:Type=\"String\">");
content.append(dt.getRow(index).getString("REVIEWTIMER"));
content.append("</ss:Data></ss:Cell>\n");
content.append("</ss:Row>\n");
index++;
}
buffer.append("<?xml version=\"1.0\" encoding=\"GBK\"?>\n");
buffer.append("<?mso-application progid=\"Excel.Sheet\"?>\n");
buffer.append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n");
buffer.append("xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n");
buffer.append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n");
buffer.append("xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n");
buffer.append("xmlns:c=\"urn:schemas-microsoft-com:office:component:spreadsheet\"\n");
buffer.append("xmlns:html=\"http://www.w3.org/TR/REC-html40\">\n");
buffer.append("<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">\n");
buffer.append("<LastAuthor>janage</LastAuthor>\n");
buffer.append("<Created>2005-12-09T01:49:38Z</Created>\n");
buffer.append("<Version>11.5606</Version>\n");
buffer.append("</DocumentProperties>\n");
buffer.append("<ExcelWorkbook xmlns=\"urn:schemas-microsoft-com:office:excel\">\n");
buffer.append("<WindowHeight>10005</WindowHeight>\n");
buffer.append("<WindowWidth>10005</WindowWidth>\n");
buffer.append("<WindowTopX>120</WindowTopX>\n");
buffer.append("<WindowTopY>135</WindowTopY>\n");
buffer.append("<ProtectStructure>False</ProtectStructure>\n");
buffer.append("<ProtectWindows>False</ProtectWindows>\n");
buffer.append("</ExcelWorkbook>\n");
buffer.append("<Styles>\n");
buffer.append("<Style ss:ID=\"Default\" ss:Name=\"Normal\">\n");
buffer.append("<Alignment ss:Vertical=\"Center\"/>\n");
buffer.append("<Font ss:FontName=\"宋体\" x:CharSet=\"134\" ss:Size=\"12\"/>\n");
buffer.append("</Style>\n");
buffer.append("<Style ss:ID=\"s21\">\n");
buffer.append("<Alignment ss:Vertical=\"Bottom\"/>\n");
buffer.append("<Font ss:FontName=\"宋体\"/>\n");
buffer.append("</Style>\n");
buffer.append("<Style ss:ID=\"s22\">\n");
buffer.append("<Alignment ss:Horizontal=\"Center\" ss:Vertical=\"Center\"/>\n");
buffer.append("<Font ss:FontName=\"宋体\" ss:Bold=\"1\"/>\n");
buffer.append("</Style>\n");
buffer.append("<Style ss:ID=\"s23\">\n");
buffer.append("<Alignment ss:Horizontal=\"Center\" ss:Vertical=\"Bottom\"/>\n");
buffer.append("<Font ss:FontName=\"宋体\"/>\n");
buffer.append("</Style>\n");
buffer.append("</Styles>\n");
buffer.append("<Worksheet ss:Name=\""+getHTMLString(sTitle)+"\">\n");
buffer.append("<Table ss:ExpandedColumnCount=\"5\" ss:ExpandedRowCount=\"37\" x:FullColumns=\"1\"\n");
buffer.append("x:FullRows=\"1\" ss:StyleID=\"s21\" ss:DefaultColumnWidth=\"54\">\n");
buffer.append("<Column ss:StyleID=\"s23\" ss:AutoFitWidth=\"0\" ss:Width=\"300.25\"/>\n");
buffer.append("<Column ss:StyleID=\"s21\" ss:AutoFitWidth=\"0\" ss:Width=\"163.5\"/>\n");
buffer.append("<Column ss:StyleID=\"s21\" ss:AutoFitWidth=\"0\" ss:Width=\"105\"/>\n");
buffer.append("<Column ss:StyleID=\"s21\" ss:AutoFitWidth=\"0\" ss:Width=\"107.25\"/>\n");
buffer.append("<Column ss:StyleID=\"s21\" ss:AutoFitWidth=\"0\" ss:Width=\"303.75\"/>\n");
buffer.append(content);
buffer.append("</Table>\n</Worksheet>\n");
buffer.append("</Workbook>\n");
//ExtString.replace(buffer, "&", "&");
//ExtString.replace(buffer, "<", "<");
//ExtString.replace(buffer, ">", ">");
//ExtString.replace(buffer, "\"", """);
response.reset();
response.setContentType("application/vnd.ms-excel; charset=gbk");
out.print(buffer);
out.close();
return ;
}
}
catch(Exception ex){
FileLogger.getLogger().warn(ex.getMessage(),ex);
}
%>
<html>
<head>
<meta content="text/html; charset=GB18030" http-equiv="content-type"/>
<title><%=sTitle%></title>
<link href="../../common/style/main.css" rel="stylesheet" type="text/css"/>
</head>
<body style="margin: 0px">
<object width="100%" height="100%" classid="CLSID:0002E551-0000-0000-C000-000000000046" codebase="/manager/owc11.exe">
<param name="DataType" value="XMLDATA">
<param name="XMLData" value="<%= buffer%>">
<table width='100%' cellpadding='0' cellspacing='0' border='0' height='8'>
<tr>
<td bgColor='#336699' height='15%' width='10%'> </td>
<td bgColor='#666666'width='85%'>
<font face='宋体' color='white' size='4'>
<b> 您的机器缺少Microsoft Office Web Components</b>
</font>
</td>
</tr>
<tr>
<td bgColor='#cccccc'> </td>
<td bgColor='#cccccc'><br>
<font face='宋体' size='2'>直接显示Excel数据需要 Microsoft Office Web Components。
<p align='center'> 一般装完Office后会自动安装该组件.</p></font><p><font face='宋体' size='2'>此网页同时要求 Microsoft Internet Explorer 5.01 或更高版本。</p><p align='center'><a href='http://www.microsoft.com/windows/ie/default.htm'> 单击此处安装最新的 Internet Explorer</a>.</font><br> </td></tr>
<tr>
<td bgColor='#cccccc'> </td>
<td bgColor='#cccccc'><form action='reviewExcel.jsp' method='post'>
<input type='hidden' name='researchId' value='<%= researchId%>'/>
<input type='hidden' name='OPENMODE' value='excel'/>
<font face='宋体' size='2'>您还可以点击<input type='submit' value='这里'>将Excel数据下载并保存到磁盘中</font>
</form></td>
</tr>
</table>
</object>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -