Simple implementation of the web application exports Excel report
In web applications, many data often export into an Excel document. It is more complicated in the way with special generation of real Excel documents. So it is often implemented in a simple way, so that the report is saved as HTML format, then open with Excel.
Implementation: First, use JSP to implement the HTML version of the report in step second, set the cyponse's contentType for the EXCEL format <% response.setContentType ("Application / VND.MS-Excel; Charset = GBK" in the JSP page header. %>%>
Chinese problem:
When you find the source code, you find a word in the JSP file in the JSP file, add a line in the head of the JSP file.
<% @ Page ContentType = "text / html; charset = GB2312"%>
When you look at the source code, you find that the text is Chinese, but use Excel to open it to garbled, add it in and
It is also similar to the processing method with servlet.
Implementation: Test.jsp
<% @ page contenttype = "text / html; charset = GBK"%>
<% respternse.setContentType ("Application / VND.MS-Excel; Charset = GBK");%>
Project td> | Meter unit td> | Full period payment rate td>
TR> Table> body> Html>
转载请注明原文地址:https://www.9cbs.com/read-47588.html New Post(0)
|